1 /* 2 * Copyright (c) 2013, 2016, 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 * @key headful 44 * @bug 7172833 45 * @summary java.awt.Toolkit methods is/setDynamicLayout() should be consistent. 46 * @author Sergey Bylokhov 47 */ 48 public final class bug7172833 { 49 50 public static void main(final String[] args) throws Exception { 51 final StubbedToolkit t = new StubbedToolkit(); 52 53 t.setDynamicLayout(true); 54 if(!t.isDynamicLayoutSet()){ 55 throw new RuntimeException("'true' expected but 'false' returned"); 56 } 57 58 t.setDynamicLayout(false); 59 if(t.isDynamicLayoutSet()){ 60 throw new RuntimeException("'false' expected but 'true' returned"); 61 } 62 } 63 64 static final class StubbedToolkit extends Toolkit { 65 66 @Override 67 protected boolean isDynamicLayoutSet() throws HeadlessException { 68 return super.isDynamicLayoutSet(); 69 } 70 71 @Override 72 protected DesktopPeer createDesktopPeer(final Desktop target) 73 throws HeadlessException { 74 return null; 75 } 76 77 @Override 78 protected ButtonPeer createButton(final Button target) 79 throws HeadlessException { 80 return null; 81 } 82 83 @Override 84 protected TextFieldPeer createTextField(final TextField target) 85 throws HeadlessException { 86 return null; 87 } 88 89 @Override 90 protected LabelPeer createLabel(final Label target) throws HeadlessException { 91 return null; 92 } 93 94 @Override 95 protected ListPeer createList(final List target) throws HeadlessException { 96 return null; 97 } 98 99 @Override 100 protected CheckboxPeer createCheckbox(final Checkbox target) 101 throws HeadlessException { 102 return null; 103 } 104 105 @Override 106 protected ScrollbarPeer createScrollbar(final Scrollbar target) 107 throws HeadlessException { 108 return null; 109 } 110 111 @Override 112 protected ScrollPanePeer createScrollPane(final ScrollPane target) 113 throws HeadlessException { 114 return null; 115 } 116 117 @Override 118 protected TextAreaPeer createTextArea(final TextArea target) 119 throws HeadlessException { 120 return null; 121 } 122 123 @Override 124 protected ChoicePeer createChoice(final Choice target) 125 throws HeadlessException { 126 return null; 127 } 128 129 @Override 130 protected FramePeer createFrame(final Frame target) throws HeadlessException { 131 return null; 132 } 133 134 @Override 135 protected CanvasPeer createCanvas(final Canvas target) { 136 return null; 137 } 138 139 @Override 140 protected PanelPeer createPanel(final Panel target) { 141 return null; 142 } 143 144 @Override 145 protected WindowPeer createWindow(final Window target) 146 throws HeadlessException { 147 return null; 148 } 149 150 @Override 151 protected DialogPeer createDialog(final Dialog target) 152 throws HeadlessException { 153 return null; 154 } 155 156 @Override 157 protected MenuBarPeer createMenuBar(final MenuBar target) 158 throws HeadlessException { 159 return null; 160 } 161 162 @Override 163 protected MenuPeer createMenu(final Menu target) throws HeadlessException { 164 return null; 165 } 166 167 @Override 168 protected PopupMenuPeer createPopupMenu(final PopupMenu target) 169 throws HeadlessException { 170 return null; 171 } 172 173 @Override 174 protected MenuItemPeer createMenuItem(final MenuItem target) 175 throws HeadlessException { 176 return null; 177 } 178 179 @Override 180 protected FileDialogPeer createFileDialog(final FileDialog target) 181 throws HeadlessException { 182 return null; 183 } 184 185 @Override 186 protected CheckboxMenuItemPeer createCheckboxMenuItem( 187 final CheckboxMenuItem target) throws HeadlessException { 188 return null; 189 } 190 191 @Override 192 protected FontPeer getFontPeer(final String name, final int style) { 193 return null; 194 } 195 196 @Override 197 public Dimension getScreenSize() throws HeadlessException { 198 return null; 199 } 200 201 @Override 202 public int getScreenResolution() throws HeadlessException { 203 return 0; 204 } 205 206 @Override 207 public ColorModel getColorModel() throws HeadlessException { 208 return null; 209 } 210 211 @Override 212 public String[] getFontList() { 213 return new String[0]; 214 } 215 216 @Override 217 public FontMetrics getFontMetrics(final Font font) { 218 return null; 219 } 220 221 @Override 222 public void sync() { 223 224 } 225 226 @Override 227 public Image getImage(final String filename) { 228 return null; 229 } 230 231 @Override 232 public Image getImage(final URL url) { 233 return null; 234 } 235 236 @Override 237 public Image createImage(final String filename) { 238 return null; 239 } 240 241 @Override 242 public Image createImage(final URL url) { 243 return null; 244 } 245 246 @Override 247 public boolean prepareImage( 248 final Image image, final int width, final int height, 249 final ImageObserver observer) { 250 return false; 251 } 252 253 @Override 254 public int checkImage(final Image image, final int width, final int height, 255 final ImageObserver observer) { 256 return 0; 257 } 258 259 @Override 260 public Image createImage(final ImageProducer producer) { 261 return null; 262 } 263 264 @Override 265 public Image createImage(final byte[] imagedata, final int imageoffset, 266 final int imagelength) { 267 return null; 268 } 269 270 @Override 271 public PrintJob getPrintJob(final Frame frame, final String jobtitle, 272 final Properties props) { 273 return null; 274 } 275 276 @Override 277 public void beep() { 278 279 } 280 281 @Override 282 public Clipboard getSystemClipboard() throws HeadlessException { 283 return null; 284 } 285 286 @Override 287 protected EventQueue getSystemEventQueueImpl() { 288 return null; 289 } 290 291 @Override 292 public DragSourceContextPeer createDragSourceContextPeer( 293 final DragGestureEvent dge) throws InvalidDnDOperationException { 294 return null; 295 } 296 297 @Override 298 public boolean isModalityTypeSupported( 299 final Dialog.ModalityType modalityType) { 300 return false; 301 } 302 303 @Override 304 public boolean isModalExclusionTypeSupported( 305 final Dialog.ModalExclusionType modalExclusionType) { 306 return false; 307 } 308 309 @Override 310 public Map<TextAttribute, ?> mapInputMethodHighlight( 311 final InputMethodHighlight highlight) throws HeadlessException { 312 return null; 313 } 314 } 315 }