1 /* 2 * Copyright (c) 2011, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.awt; 27 28 import java.awt.*; 29 import java.awt.dnd.*; 30 import java.awt.dnd.peer.DragSourceContextPeer; 31 import java.awt.im.InputMethodHighlight; 32 import java.awt.im.spi.InputMethodDescriptor; 33 import java.awt.image.*; 34 import java.awt.datatransfer.Clipboard; 35 import java.awt.peer.*; 36 import java.util.Map; 37 import java.util.Properties; 38 39 /* 40 * HToolkit is a platform independent Toolkit used 41 * with the HeadlessToolkit. It is primarily used 42 * in embedded JRE's that do not have sun/awt/X11 classes. 43 */ 44 public class HToolkit extends SunToolkit 45 implements ComponentFactory { 46 47 private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() { 48 public void setCurrentFocusedWindow(Window win) {} 49 public Window getCurrentFocusedWindow() { return null; } 50 public void setCurrentFocusOwner(Component comp) {} 51 public Component getCurrentFocusOwner() { return null; } 52 public void clearGlobalFocusOwner(Window activeWindow) {} 53 }; 54 55 public HToolkit() { 56 } 57 58 /* 59 * Component peer objects - unsupported. 60 */ 61 62 public WindowPeer createWindow(Window target) 63 throws HeadlessException { 64 throw new HeadlessException(); 65 } 66 67 public FramePeer createLightweightFrame(LightweightFrame target) 68 throws HeadlessException { 69 throw new HeadlessException(); 70 } 71 72 public FramePeer createFrame(Frame target) 73 throws HeadlessException { 74 throw new HeadlessException(); 75 } 76 77 public DialogPeer createDialog(Dialog target) 78 throws HeadlessException { 79 throw new HeadlessException(); 80 } 81 82 public ButtonPeer createButton(Button target) 83 throws HeadlessException { 84 throw new HeadlessException(); 85 } 86 87 public TextFieldPeer createTextField(TextField target) 88 throws HeadlessException { 89 throw new HeadlessException(); 90 } 91 92 public ChoicePeer createChoice(Choice target) 93 throws HeadlessException { 94 throw new HeadlessException(); 95 } 96 97 public LabelPeer createLabel(Label target) 98 throws HeadlessException { 99 throw new HeadlessException(); 100 } 101 102 public ListPeer createList(List target) 103 throws HeadlessException { 104 throw new HeadlessException(); 105 } 106 107 public CheckboxPeer createCheckbox(Checkbox target) 108 throws HeadlessException { 109 throw new HeadlessException(); 110 } 111 112 public ScrollbarPeer createScrollbar(Scrollbar target) 113 throws HeadlessException { 114 throw new HeadlessException(); 115 } 116 117 public ScrollPanePeer createScrollPane(ScrollPane target) 118 throws HeadlessException { 119 throw new HeadlessException(); 120 } 121 122 public TextAreaPeer createTextArea(TextArea target) 123 throws HeadlessException { 124 throw new HeadlessException(); 125 } 126 127 public FileDialogPeer createFileDialog(FileDialog target) 128 throws HeadlessException { 129 throw new HeadlessException(); 130 } 131 132 public MenuBarPeer createMenuBar(MenuBar target) 133 throws HeadlessException { 134 throw new HeadlessException(); 135 } 136 137 public MenuPeer createMenu(Menu target) 138 throws HeadlessException { 139 throw new HeadlessException(); 140 } 141 142 public PopupMenuPeer createPopupMenu(PopupMenu target) 143 throws HeadlessException { 144 throw new HeadlessException(); 145 } 146 147 public MenuItemPeer createMenuItem(MenuItem target) 148 throws HeadlessException { 149 throw new HeadlessException(); 150 } 151 152 public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) 153 throws HeadlessException { 154 throw new HeadlessException(); 155 } 156 157 public DragSourceContextPeer createDragSourceContextPeer( 158 DragGestureEvent dge) 159 throws InvalidDnDOperationException { 160 throw new InvalidDnDOperationException("Headless environment"); 161 } 162 163 public RobotPeer createRobot(Robot target, GraphicsDevice screen) 164 throws AWTException, HeadlessException { 165 throw new HeadlessException(); 166 } 167 168 public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() { 169 // See 6833019. 170 return kfmPeer; 171 } 172 173 public TrayIconPeer createTrayIcon(TrayIcon target) 174 throws HeadlessException { 175 throw new HeadlessException(); 176 } 177 178 public SystemTrayPeer createSystemTray(SystemTray target) 179 throws HeadlessException { 180 throw new HeadlessException(); 181 } 182 183 public boolean isTraySupported() { 184 return false; 185 } 186 187 public GlobalCursorManager getGlobalCursorManager() 188 throws HeadlessException { 189 throw new HeadlessException(); 190 } 191 192 /* 193 * Headless toolkit - unsupported. 194 */ 195 protected void loadSystemColors(int[] systemColors) 196 throws HeadlessException { 197 throw new HeadlessException(); 198 } 199 200 public ColorModel getColorModel() 201 throws HeadlessException { 202 throw new HeadlessException(); 203 } 204 205 public int getScreenResolution() 206 throws HeadlessException { 207 throw new HeadlessException(); 208 } 209 210 public Map mapInputMethodHighlight(InputMethodHighlight highlight) 211 throws HeadlessException { 212 throw new HeadlessException(); 213 } 214 215 public int getMenuShortcutKeyMask() 216 throws HeadlessException { 217 throw new HeadlessException(); 218 } 219 220 public boolean getLockingKeyState(int keyCode) 221 throws UnsupportedOperationException { 222 throw new HeadlessException(); 223 } 224 225 public void setLockingKeyState(int keyCode, boolean on) 226 throws UnsupportedOperationException { 227 throw new HeadlessException(); 228 } 229 230 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) 231 throws IndexOutOfBoundsException, HeadlessException { 232 throw new HeadlessException(); 233 } 234 235 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) 236 throws HeadlessException { 237 throw new HeadlessException(); 238 } 239 240 public int getMaximumCursorColors() 241 throws HeadlessException { 242 throw new HeadlessException(); 243 } 244 245 public <T extends DragGestureRecognizer> T 246 createDragGestureRecognizer(Class<T> abstractRecognizerClass, 247 DragSource ds, Component c, 248 int srcActions, DragGestureListener dgl) 249 { 250 return null; 251 } 252 253 public int getScreenHeight() 254 throws HeadlessException { 255 throw new HeadlessException(); 256 } 257 258 public int getScreenWidth() 259 throws HeadlessException { 260 throw new HeadlessException(); 261 } 262 263 public Dimension getScreenSize() 264 throws HeadlessException { 265 throw new HeadlessException(); 266 } 267 268 public Insets getScreenInsets(GraphicsConfiguration gc) 269 throws HeadlessException { 270 throw new HeadlessException(); 271 } 272 273 public void setDynamicLayout(boolean dynamic) 274 throws HeadlessException { 275 throw new HeadlessException(); 276 } 277 278 protected boolean isDynamicLayoutSet() 279 throws HeadlessException { 280 throw new HeadlessException(); 281 } 282 283 public boolean isDynamicLayoutActive() 284 throws HeadlessException { 285 throw new HeadlessException(); 286 } 287 288 public Clipboard getSystemClipboard() 289 throws HeadlessException { 290 throw new HeadlessException(); 291 } 292 293 /* 294 * Printing 295 */ 296 public PrintJob getPrintJob(Frame frame, String jobtitle, 297 JobAttributes jobAttributes, 298 PageAttributes pageAttributes) { 299 if (frame != null) { 300 // Should never happen 301 throw new HeadlessException(); 302 } 303 throw new IllegalArgumentException( 304 "PrintJob not supported in a headless environment"); 305 } 306 307 public PrintJob getPrintJob(Frame frame, String doctitle, Properties props) 308 { 309 if (frame != null) { 310 // Should never happen 311 throw new HeadlessException(); 312 } 313 throw new IllegalArgumentException( 314 "PrintJob not supported in a headless environment"); 315 } 316 317 /* 318 * Headless toolkit - supported. 319 */ 320 321 public void sync() { 322 // Do nothing 323 } 324 325 protected boolean syncNativeQueue(final long timeout) { 326 return false; 327 } 328 329 public void beep() { 330 // Send alert character 331 System.out.write(0x07); 332 } 333 334 335 /* 336 * Fonts 337 */ 338 public FontPeer getFontPeer(String name, int style) { 339 return (FontPeer)null; 340 } 341 342 /* 343 * Modality 344 */ 345 public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { 346 return false; 347 } 348 349 public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) { 350 return false; 351 } 352 353 public boolean isDesktopSupported() { 354 return false; 355 } 356 357 public DesktopPeer createDesktopPeer(Desktop target) 358 throws HeadlessException{ 359 throw new HeadlessException(); 360 } 361 362 public boolean isWindowOpacityControlSupported() { 363 return false; 364 } 365 366 public boolean isWindowShapingSupported() { 367 return false; 368 } 369 370 public boolean isWindowTranslucencySupported() { 371 return false; 372 } 373 374 public void grab(Window w) { } 375 376 public void ungrab(Window w) { } 377 378 protected boolean syncNativeQueue() { return false; } 379 380 public InputMethodDescriptor getInputMethodAdapterDescriptor() 381 throws AWTException 382 { 383 return (InputMethodDescriptor)null; 384 } 385 }