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 createFrame(Frame target) 68 throws HeadlessException { 69 throw new HeadlessException(); 70 } 71 72 public DialogPeer createDialog(Dialog target) 73 throws HeadlessException { 74 throw new HeadlessException(); 75 } 76 77 public ButtonPeer createButton(Button target) 78 throws HeadlessException { 79 throw new HeadlessException(); 80 } 81 82 public TextFieldPeer createTextField(TextField target) 83 throws HeadlessException { 84 throw new HeadlessException(); 85 } 86 87 public ChoicePeer createChoice(Choice target) 88 throws HeadlessException { 89 throw new HeadlessException(); 90 } 91 92 public LabelPeer createLabel(Label target) 93 throws HeadlessException { 94 throw new HeadlessException(); 95 } 96 97 public ListPeer createList(List target) 98 throws HeadlessException { 99 throw new HeadlessException(); 100 } 101 102 public CheckboxPeer createCheckbox(Checkbox target) 103 throws HeadlessException { 104 throw new HeadlessException(); 105 } 106 107 public ScrollbarPeer createScrollbar(Scrollbar target) 108 throws HeadlessException { 109 throw new HeadlessException(); 110 } 111 112 public ScrollPanePeer createScrollPane(ScrollPane target) 113 throws HeadlessException { 114 throw new HeadlessException(); 115 } 116 117 public TextAreaPeer createTextArea(TextArea target) 118 throws HeadlessException { 119 throw new HeadlessException(); 120 } 121 122 public FileDialogPeer createFileDialog(FileDialog target) 123 throws HeadlessException { 124 throw new HeadlessException(); 125 } 126 127 public MenuBarPeer createMenuBar(MenuBar target) 128 throws HeadlessException { 129 throw new HeadlessException(); 130 } 131 132 public MenuPeer createMenu(Menu target) 133 throws HeadlessException { 134 throw new HeadlessException(); 135 } 136 137 public PopupMenuPeer createPopupMenu(PopupMenu target) 138 throws HeadlessException { 139 throw new HeadlessException(); 140 } 141 142 public MenuItemPeer createMenuItem(MenuItem target) 143 throws HeadlessException { 144 throw new HeadlessException(); 145 } 146 147 public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) 148 throws HeadlessException { 149 throw new HeadlessException(); 150 } 151 152 public DragSourceContextPeer createDragSourceContextPeer( 153 DragGestureEvent dge) 154 throws InvalidDnDOperationException { 155 throw new InvalidDnDOperationException("Headless environment"); 156 } 157 158 public RobotPeer createRobot(Robot target, GraphicsDevice screen) 159 throws AWTException, HeadlessException { 160 throw new HeadlessException(); 161 } 162 163 public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() { 164 // See 6833019. 165 return kfmPeer; 166 } 167 168 public TrayIconPeer createTrayIcon(TrayIcon target) 169 throws HeadlessException { 170 throw new HeadlessException(); 171 } 172 173 public SystemTrayPeer createSystemTray(SystemTray target) 174 throws HeadlessException { 175 throw new HeadlessException(); 176 } 177 178 public boolean isTraySupported() { 179 return false; 180 } 181 182 public GlobalCursorManager getGlobalCursorManager() 183 throws HeadlessException { 184 throw new HeadlessException(); 185 } 186 187 /* 188 * Headless toolkit - unsupported. 189 */ 190 protected void loadSystemColors(int[] systemColors) 191 throws HeadlessException { 192 throw new HeadlessException(); 193 } 194 195 public ColorModel getColorModel() 196 throws HeadlessException { 197 throw new HeadlessException(); 198 } 199 200 public int getScreenResolution() 201 throws HeadlessException { 202 throw new HeadlessException(); 203 } 204 205 public Map mapInputMethodHighlight(InputMethodHighlight highlight) 206 throws HeadlessException { 207 throw new HeadlessException(); 208 } 209 210 public int getMenuShortcutKeyMask() 211 throws HeadlessException { 212 throw new HeadlessException(); 213 } 214 215 public boolean getLockingKeyState(int keyCode) 216 throws UnsupportedOperationException { 217 throw new HeadlessException(); 218 } 219 220 public void setLockingKeyState(int keyCode, boolean on) 221 throws UnsupportedOperationException { 222 throw new HeadlessException(); 223 } 224 225 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) 226 throws IndexOutOfBoundsException, HeadlessException { 227 throw new HeadlessException(); 228 } 229 230 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) 231 throws HeadlessException { 232 throw new HeadlessException(); 233 } 234 235 public int getMaximumCursorColors() 236 throws HeadlessException { 237 throw new HeadlessException(); 238 } 239 240 public <T extends DragGestureRecognizer> T 241 createDragGestureRecognizer(Class<T> abstractRecognizerClass, 242 DragSource ds, Component c, 243 int srcActions, DragGestureListener dgl) 244 { 245 return null; 246 } 247 248 public int getScreenHeight() 249 throws HeadlessException { 250 throw new HeadlessException(); 251 } 252 253 public int getScreenWidth() 254 throws HeadlessException { 255 throw new HeadlessException(); 256 } 257 258 public Dimension getScreenSize() 259 throws HeadlessException { 260 throw new HeadlessException(); 261 } 262 263 public Insets getScreenInsets(GraphicsConfiguration gc) 264 throws HeadlessException { 265 throw new HeadlessException(); 266 } 267 268 public void setDynamicLayout(boolean dynamic) 269 throws HeadlessException { 270 throw new HeadlessException(); 271 } 272 273 protected boolean isDynamicLayoutSet() 274 throws HeadlessException { 275 throw new HeadlessException(); 276 } 277 278 public boolean isDynamicLayoutActive() 279 throws HeadlessException { 280 throw new HeadlessException(); 281 } 282 283 public Clipboard getSystemClipboard() 284 throws HeadlessException { 285 throw new HeadlessException(); 286 } 287 288 /* 289 * Printing 290 */ 291 public PrintJob getPrintJob(Frame frame, String jobtitle, 292 JobAttributes jobAttributes, 293 PageAttributes pageAttributes) { 294 if (frame != null) { 295 // Should never happen 296 throw new HeadlessException(); 297 } 298 throw new IllegalArgumentException( 299 "PrintJob not supported in a headless environment"); 300 } 301 302 public PrintJob getPrintJob(Frame frame, String doctitle, Properties props) 303 { 304 if (frame != null) { 305 // Should never happen 306 throw new HeadlessException(); 307 } 308 throw new IllegalArgumentException( 309 "PrintJob not supported in a headless environment"); 310 } 311 312 /* 313 * Headless toolkit - supported. 314 */ 315 316 public void sync() { 317 // Do nothing 318 } 319 320 protected boolean syncNativeQueue(final long timeout) { 321 return false; 322 } 323 324 public void beep() { 325 // Send alert character 326 System.out.write(0x07); 327 } 328 329 330 /* 331 * Fonts 332 */ 333 public FontPeer getFontPeer(String name, int style) { 334 return (FontPeer)null; 335 } 336 337 /* 338 * Modality 339 */ 340 public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { 341 return false; 342 } 343 344 public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) { 345 return false; 346 } 347 348 public boolean isDesktopSupported() { 349 return false; 350 } 351 352 public DesktopPeer createDesktopPeer(Desktop target) 353 throws HeadlessException{ 354 throw new HeadlessException(); 355 } 356 357 public boolean isWindowOpacityControlSupported() { 358 return false; 359 } 360 361 public boolean isWindowShapingSupported() { 362 return false; 363 } 364 365 public boolean isWindowTranslucencySupported() { 366 return false; 367 } 368 369 public void grab(Window w) { } 370 371 public void ungrab(Window w) { } 372 373 protected boolean syncNativeQueue() { return false; } 374 375 public InputMethodDescriptor getInputMethodAdapterDescriptor() 376 throws AWTException 377 { 378 return (InputMethodDescriptor)null; 379 } 380 }