1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 import java.awt.*; 26 import java.awt.datatransfer.Clipboard; 27 import java.awt.dnd.DragGestureEvent; 28 import java.awt.dnd.InvalidDnDOperationException; 29 import java.awt.dnd.peer.DragSourceContextPeer; 30 import java.awt.font.TextAttribute; 31 import java.awt.im.InputMethodHighlight; 32 import java.awt.image.ColorModel; 33 import java.awt.image.ImageObserver; 34 import java.awt.image.ImageProducer; 35 import java.awt.peer.*; 36 import java.net.URL; 37 import java.util.Map; 38 import java.util.Properties; 39 40 41 /** 42 * @test 43 * @bug 7172833 44 * @summary java.awt.Toolkit methods is/setDynamicLayout() should be consistent. 45 * @author Sergey Bylokhov 46 */ 47 public final class bug7172833 { 48 49 public static void main(final String[] args) throws Exception { 50 final StubbedToolkit t = new StubbedToolkit(); 51 52 t.setDynamicLayout(true); 53 if(!t.isDynamicLayoutSet()){ 54 throw new RuntimeException("'true' expected but 'false' returned"); 55 } 56 57 t.setDynamicLayout(false); 58 if(t.isDynamicLayoutSet()){ 59 throw new RuntimeException("'false' expected but 'true' returned"); 60 } 61 } 62 63 static final class StubbedToolkit extends Toolkit { 64 65 @Override 66 protected boolean isDynamicLayoutSet() throws HeadlessException { 67 return super.isDynamicLayoutSet(); 68 } 69 70 @Override 71 protected DesktopPeer createDesktopPeer(final Desktop target) 72 throws HeadlessException { 73 return null; 74 } 75 76 @Override 77 protected ButtonPeer createButton(final Button target) 78 throws HeadlessException { 79 return null; 80 } 81 82 @Override 83 protected TextFieldPeer createTextField(final TextField target) 84 throws HeadlessException { 85 return null; 86 } 87 88 @Override 89 protected LabelPeer createLabel(final Label target) throws HeadlessException { 90 return null; 91 } 92 93 @Override 94 protected ListPeer createList(final List target) throws HeadlessException { 95 return null; 96 } 97 98 @Override 99 protected CheckboxPeer createCheckbox(final Checkbox target) 100 throws HeadlessException { 101 return null; 102 } 103 104 @Override 105 protected ScrollbarPeer createScrollbar(final Scrollbar target) 106 throws HeadlessException { 107 return null; 108 } 109 110 @Override 111 protected ScrollPanePeer createScrollPane(final ScrollPane target) 112 throws HeadlessException { 113 return null; 114 } 115 116 @Override 117 protected TextAreaPeer createTextArea(final TextArea target) 118 throws HeadlessException { 119 return null; 120 } 121 122 @Override 123 protected ChoicePeer createChoice(final Choice target) 124 throws HeadlessException { 125 return null; 126 } 127 128 @Override 129 protected FramePeer createFrame(final Frame target) throws HeadlessException { 130 return null; 131 } 132 133 @Override 134 protected CanvasPeer createCanvas(final Canvas target) { 135 return null; 136 } 137 138 @Override 139 protected PanelPeer createPanel(final Panel target) { 140 return null; 141 } 142 143 @Override 144 protected WindowPeer createWindow(final Window target) 145 throws HeadlessException { 146 return null; 147 } 148 149 @Override 150 protected DialogPeer createDialog(final Dialog target) 151 throws HeadlessException { 152 return null; 153 } 154 155 @Override 156 protected MenuBarPeer createMenuBar(final MenuBar target) 157 throws HeadlessException { 158 return null; 159 } 160 161 @Override 162 protected MenuPeer createMenu(final Menu target) throws HeadlessException { 163 return null; 164 } 165 166 @Override 167 protected PopupMenuPeer createPopupMenu(final PopupMenu target) 168 throws HeadlessException { 169 return null; 170 } 171 172 @Override 173 protected MenuItemPeer createMenuItem(final MenuItem target) 174 throws HeadlessException { 175 return null; 176 } 177 178 @Override 179 protected FileDialogPeer createFileDialog(final FileDialog target) 180 throws HeadlessException { 181 return null; 182 } 183 184 @Override 185 protected CheckboxMenuItemPeer createCheckboxMenuItem( 186 final CheckboxMenuItem target) throws HeadlessException { 187 return null; 188 } 189 190 @Override 191 protected FontPeer getFontPeer(final String name, final int style) { 192 return null; 193 } 194 195 @Override 196 public Dimension getScreenSize() throws HeadlessException { 197 return null; 198 } 199 200 @Override 201 public int getScreenResolution() throws HeadlessException { 202 return 0; 203 } 204 205 @Override 206 public ColorModel getColorModel() throws HeadlessException { 207 return null; 208 } 209 210 @Override 211 public String[] getFontList() { 212 return new String[0]; 213 } 214 215 @Override 216 public FontMetrics getFontMetrics(final Font font) { 217 return null; 218 } 219 220 @Override 221 public void sync() { 222 223 } 224 225 @Override 226 public Image getImage(final String filename) { 227 return null; 228 } 229 230 @Override 231 public Image getImage(final URL url) { 232 return null; 233 } 234 235 @Override 236 public Image createImage(final String filename) { 237 return null; 238 } 239 240 @Override 241 public Image createImage(final URL url) { 242 return null; 243 } 244 245 @Override 246 public boolean prepareImage( 247 final Image image, final int width, final int height, 248 final ImageObserver observer) { 249 return false; 250 } 251 252 @Override 253 public int checkImage(final Image image, final int width, final int height, 254 final ImageObserver observer) { 255 return 0; 256 } 257 258 @Override 259 public Image createImage(final ImageProducer producer) { 260 return null; 261 } 262 263 @Override 264 public Image createImage(final byte[] imagedata, final int imageoffset, 265 final int imagelength) { 266 return null; 267 } 268 269 @Override 270 public PrintJob getPrintJob(final Frame frame, final String jobtitle, 271 final Properties props) { 272 return null; 273 } 274 275 @Override 276 public void beep() { 277 278 } 279 280 @Override 281 public Clipboard getSystemClipboard() throws HeadlessException { 282 return null; 283 } 284 285 @Override 286 protected EventQueue getSystemEventQueueImpl() { 287 return null; 288 } 289 290 @Override 291 public DragSourceContextPeer createDragSourceContextPeer( 292 final DragGestureEvent dge) throws InvalidDnDOperationException { 293 return null; 294 } 295 296 @Override 297 public boolean isModalityTypeSupported( 298 final Dialog.ModalityType modalityType) { 299 return false; 300 } 301 302 @Override 303 public boolean isModalExclusionTypeSupported( 304 final Dialog.ModalExclusionType modalExclusionType) { 305 return false; 306 } 307 308 @Override 309 public Map<TextAttribute, ?> mapInputMethodHighlight( 310 final InputMethodHighlight highlight) throws HeadlessException { 311 return null; 312 } 313 } 314 }