src/java.desktop/share/classes/sun/awt/HToolkit.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2014, 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 sun.awt.datatransfer.DataTransferer;
  29 
  30 import java.awt.*;
  31 import java.awt.dnd.*;
  32 import java.awt.dnd.peer.DragSourceContextPeer;


  33 import java.awt.im.InputMethodHighlight;
  34 import java.awt.im.spi.InputMethodDescriptor;
  35 import java.awt.image.*;
  36 import java.awt.datatransfer.Clipboard;
  37 import java.awt.peer.*;


  38 import java.util.Map;
  39 import java.util.Properties;
  40 
  41 /*
  42  * HToolkit is a platform independent Toolkit used
  43  * with the HeadlessToolkit.  It is primarily used
  44  * in embedded JRE's that do not have sun/awt/X11 classes.
  45  */
  46 public class HToolkit extends SunToolkit
  47     implements ComponentFactory {
  48 
  49     private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {

  50         public void setCurrentFocusedWindow(Window win) {}

  51         public Window getCurrentFocusedWindow() { return null; }

  52         public void setCurrentFocusOwner(Component comp) {}

  53         public Component getCurrentFocusOwner() { return null; }

  54         public void clearGlobalFocusOwner(Window activeWindow) {}
  55     };
  56 
  57     public HToolkit() {
  58     }
  59 
  60     /*
  61      * Component peer objects - unsupported.
  62      */
  63 
  64     public WindowPeer createWindow(Window target)
  65         throws HeadlessException {
  66         throw new HeadlessException();
  67     }
  68 
  69     public FramePeer createLightweightFrame(LightweightFrame target)
  70         throws HeadlessException {
  71         throw new HeadlessException();
  72     }
  73 
  74     public FramePeer createFrame(Frame target)
  75         throws HeadlessException {
  76         throw new HeadlessException();
  77     }
  78 
  79     public DialogPeer createDialog(Dialog target)
  80         throws HeadlessException {
  81         throw new HeadlessException();
  82     }
  83 
  84     public ButtonPeer createButton(Button target)
  85         throws HeadlessException {
  86         throw new HeadlessException();
  87     }
  88 
  89     public TextFieldPeer createTextField(TextField target)
  90         throws HeadlessException {
  91         throw new HeadlessException();
  92     }
  93 
  94     public ChoicePeer createChoice(Choice target)
  95         throws HeadlessException {
  96         throw new HeadlessException();
  97     }
  98 
  99     public LabelPeer createLabel(Label target)
 100         throws HeadlessException {
 101         throw new HeadlessException();
 102     }
 103 
 104     public ListPeer createList(List target)
 105         throws HeadlessException {
 106         throw new HeadlessException();
 107     }
 108 
 109     public CheckboxPeer createCheckbox(Checkbox target)
 110         throws HeadlessException {
 111         throw new HeadlessException();
 112     }
 113 
 114     public ScrollbarPeer createScrollbar(Scrollbar target)
 115         throws HeadlessException {
 116         throw new HeadlessException();
 117     }
 118 
 119     public ScrollPanePeer createScrollPane(ScrollPane target)
 120         throws HeadlessException {
 121         throw new HeadlessException();
 122     }
 123 
 124     public TextAreaPeer createTextArea(TextArea target)
 125         throws HeadlessException {
 126         throw new HeadlessException();
 127     }
 128 
 129     public FileDialogPeer createFileDialog(FileDialog target)
 130         throws HeadlessException {
 131         throw new HeadlessException();
 132     }
 133 
 134     public MenuBarPeer createMenuBar(MenuBar target)
 135         throws HeadlessException {
 136         throw new HeadlessException();
 137     }
 138 
 139     public MenuPeer createMenu(Menu target)
 140         throws HeadlessException {
 141         throw new HeadlessException();
 142     }
 143 
 144     public PopupMenuPeer createPopupMenu(PopupMenu target)
 145         throws HeadlessException {
 146         throw new HeadlessException();
 147     }
 148 
 149     public MenuItemPeer createMenuItem(MenuItem target)
 150         throws HeadlessException {
 151         throw new HeadlessException();
 152     }
 153 
 154     public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
 155         throws HeadlessException {
 156         throw new HeadlessException();
 157     }
 158 
 159     public DragSourceContextPeer createDragSourceContextPeer(
 160         DragGestureEvent dge)
 161         throws InvalidDnDOperationException {
 162         throw new InvalidDnDOperationException("Headless environment");
 163     }
 164 
 165     public RobotPeer createRobot(Robot target, GraphicsDevice screen)
 166         throws AWTException, HeadlessException {
 167         throw new HeadlessException();
 168     }
 169 
 170     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
 171         // See 6833019.
 172         return kfmPeer;
 173     }
 174 

 175     public TrayIconPeer createTrayIcon(TrayIcon target)
 176       throws HeadlessException {
 177         throw new HeadlessException();
 178     }
 179 

 180     public SystemTrayPeer createSystemTray(SystemTray target)
 181       throws HeadlessException {
 182         throw new HeadlessException();
 183     }
 184 

 185     public boolean isTraySupported() {
 186         return false;
 187     }
 188 
 189     @Override
 190     public DataTransferer getDataTransferer() {
 191         return null;
 192     }
 193 
 194     public GlobalCursorManager getGlobalCursorManager()
 195         throws HeadlessException {
 196         throw new HeadlessException();
 197     }
 198 
 199     /*
 200      * Headless toolkit - unsupported.
 201      */

 202     protected void loadSystemColors(int[] systemColors)
 203         throws HeadlessException {
 204         throw new HeadlessException();
 205     }
 206 

 207     public ColorModel getColorModel()
 208         throws HeadlessException {
 209         throw new HeadlessException();
 210     }
 211 

 212     public int getScreenResolution()
 213         throws HeadlessException {
 214         throw new HeadlessException();
 215     }
 216 

 217     public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
 218             InputMethodHighlight highlight)
 219         throws HeadlessException {
 220         throw new HeadlessException();
 221     }
 222 

 223     public int getMenuShortcutKeyMask()
 224         throws HeadlessException {
 225         throw new HeadlessException();
 226     }
 227 

 228     public boolean getLockingKeyState(int keyCode)
 229         throws UnsupportedOperationException {
 230         throw new HeadlessException();
 231     }
 232 

 233     public void setLockingKeyState(int keyCode, boolean on)
 234         throws UnsupportedOperationException {
 235         throw new HeadlessException();
 236     }
 237 

 238     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
 239         throws IndexOutOfBoundsException, HeadlessException {
 240         throw new HeadlessException();
 241     }
 242 

 243     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
 244         throws HeadlessException {
 245         throw new HeadlessException();
 246     }
 247 

 248     public int getMaximumCursorColors()
 249         throws HeadlessException {
 250         throw new HeadlessException();
 251     }
 252 

 253     public <T extends DragGestureRecognizer> T
 254         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
 255                                     DragSource ds, Component c,
 256                                     int srcActions, DragGestureListener dgl)
 257     {
 258         return null;
 259     }
 260 

 261     public int getScreenHeight()
 262         throws HeadlessException {
 263         throw new HeadlessException();
 264     }
 265 

 266     public int getScreenWidth()
 267         throws HeadlessException {
 268         throw new HeadlessException();
 269     }
 270 

 271     public Dimension getScreenSize()
 272         throws HeadlessException {
 273         throw new HeadlessException();
 274     }
 275 

 276     public Insets getScreenInsets(GraphicsConfiguration gc)
 277         throws HeadlessException {
 278         throw new HeadlessException();
 279     }
 280 

 281     public void setDynamicLayout(boolean dynamic)
 282         throws HeadlessException {
 283         throw new HeadlessException();
 284     }
 285 

 286     protected boolean isDynamicLayoutSet()
 287         throws HeadlessException {
 288         throw new HeadlessException();
 289     }
 290 

 291     public boolean isDynamicLayoutActive()
 292         throws HeadlessException {
 293         throw new HeadlessException();
 294     }
 295 

 296     public Clipboard getSystemClipboard()
 297         throws HeadlessException {
 298         throw new HeadlessException();
 299     }
 300 
 301     /*
 302      * Printing
 303      */

 304     public PrintJob getPrintJob(Frame frame, String jobtitle,
 305         JobAttributes jobAttributes,
 306         PageAttributes pageAttributes) {
 307         if (frame != null) {
 308             // Should never happen
 309             throw new HeadlessException();
 310         }
 311         throw new IllegalArgumentException(
 312                 "PrintJob not supported in a headless environment");
 313     }
 314 

 315     public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
 316     {
 317         if (frame != null) {
 318             // Should never happen
 319             throw new HeadlessException();
 320         }
 321         throw new IllegalArgumentException(
 322                 "PrintJob not supported in a headless environment");
 323     }
 324 
 325     /*
 326      * Headless toolkit - supported.
 327      */
 328 

 329     public void sync() {
 330         // Do nothing
 331     }
 332 

 333     protected boolean syncNativeQueue(final long timeout) {
 334         return false;
 335     }
 336 

 337     public void beep() {
 338         // Send alert character
 339         System.out.write(0x07);
 340     }
 341 
 342 
 343     /*
 344      * Fonts
 345      */
 346     public FontPeer getFontPeer(String name, int style) {
 347         return (FontPeer)null;
 348     }
 349 
 350     /*
 351      * Modality
 352      */

 353     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 354         return false;
 355     }
 356 

 357     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 358         return false;
 359     }
 360 

 361     public boolean isDesktopSupported() {
 362         return false;
 363     }
 364 
 365     public DesktopPeer createDesktopPeer(Desktop target)
 366     throws HeadlessException{
 367         throw new HeadlessException();
 368     }
 369 
 370     public boolean isWindowOpacityControlSupported() {
 371         return false;
 372     }
 373 

 374     public boolean isWindowShapingSupported() {
 375         return false;
 376     }
 377 

 378     public boolean isWindowTranslucencySupported() {
 379         return false;
 380     }
 381 

 382     public  void grab(Window w) { }
 383 

 384     public void ungrab(Window w) { }
 385 
 386     protected boolean syncNativeQueue() { return false; }
 387 

 388     public InputMethodDescriptor getInputMethodAdapterDescriptor()
 389         throws AWTException
 390     {
 391         return (InputMethodDescriptor)null;
 392     }
 393 }
   1 /*
   2  * Copyright (c) 2011, 2015, 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.datatransfer.Clipboard;
  30 import java.awt.dnd.DragGestureListener;
  31 import java.awt.dnd.DragGestureRecognizer;
  32 import java.awt.dnd.DragSource;
  33 import java.awt.im.InputMethodHighlight;
  34 import java.awt.im.spi.InputMethodDescriptor;
  35 import java.awt.image.ColorModel;
  36 import java.awt.peer.FramePeer;
  37 import java.awt.peer.KeyboardFocusManagerPeer;
  38 import java.awt.peer.SystemTrayPeer;
  39 import java.awt.peer.TrayIconPeer;
  40 import java.util.Map;
  41 import java.util.Properties;
  42 
  43 /*
  44  * HToolkit is a platform independent Toolkit used
  45  * with the HeadlessToolkit.  It is primarily used
  46  * in embedded JRE's that do not have sun/awt/X11 classes.
  47  */
  48 public class HToolkit extends SunToolkit
  49     implements ComponentFactory {
  50 
  51     private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
  52         @Override
  53         public void setCurrentFocusedWindow(Window win) {}
  54         @Override
  55         public Window getCurrentFocusedWindow() { return null; }
  56         @Override
  57         public void setCurrentFocusOwner(Component comp) {}
  58         @Override
  59         public Component getCurrentFocusOwner() { return null; }
  60         @Override
  61         public void clearGlobalFocusOwner(Window activeWindow) {}
  62     };
  63 
  64     public HToolkit() {
  65     }
  66 
  67     /*
  68      * Component peer objects - unsupported.
  69      */
  70 
  71     @Override




  72     public FramePeer createLightweightFrame(LightweightFrame target)
  73         throws HeadlessException {
  74         throw new HeadlessException();
  75     }
  76 
  77     @Override































































































  78     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
  79         // See 6833019.
  80         return kfmPeer;
  81     }
  82 
  83     @Override
  84     public TrayIconPeer createTrayIcon(TrayIcon target)
  85       throws HeadlessException {
  86         throw new HeadlessException();
  87     }
  88 
  89     @Override
  90     public SystemTrayPeer createSystemTray(SystemTray target)
  91       throws HeadlessException {
  92         throw new HeadlessException();
  93     }
  94 
  95     @Override
  96     public boolean isTraySupported() {
  97         return false;
  98     }
  99 





 100     public GlobalCursorManager getGlobalCursorManager()
 101         throws HeadlessException {
 102         throw new HeadlessException();
 103     }
 104 
 105     /*
 106      * Headless toolkit - unsupported.
 107      */
 108     @Override
 109     protected void loadSystemColors(int[] systemColors)
 110         throws HeadlessException {
 111         throw new HeadlessException();
 112     }
 113 
 114     @Override
 115     public ColorModel getColorModel()
 116         throws HeadlessException {
 117         throw new HeadlessException();
 118     }
 119 
 120     @Override
 121     public int getScreenResolution()
 122         throws HeadlessException {
 123         throw new HeadlessException();
 124     }
 125 
 126     @Override
 127     public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
 128             InputMethodHighlight highlight)
 129         throws HeadlessException {
 130         throw new HeadlessException();
 131     }
 132 
 133     @Override
 134     public int getMenuShortcutKeyMask()
 135         throws HeadlessException {
 136         throw new HeadlessException();
 137     }
 138 
 139     @Override
 140     public boolean getLockingKeyState(int keyCode)
 141         throws UnsupportedOperationException {
 142         throw new HeadlessException();
 143     }
 144 
 145     @Override
 146     public void setLockingKeyState(int keyCode, boolean on)
 147         throws UnsupportedOperationException {
 148         throw new HeadlessException();
 149     }
 150 
 151     @Override
 152     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
 153         throws IndexOutOfBoundsException, HeadlessException {
 154         throw new HeadlessException();
 155     }
 156 
 157     @Override
 158     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
 159         throws HeadlessException {
 160         throw new HeadlessException();
 161     }
 162 
 163     @Override
 164     public int getMaximumCursorColors()
 165         throws HeadlessException {
 166         throw new HeadlessException();
 167     }
 168 
 169     @Override
 170     public <T extends DragGestureRecognizer> T
 171         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
 172                                     DragSource ds, Component c,
 173                                     int srcActions, DragGestureListener dgl)
 174     {
 175         return null;
 176     }
 177 
 178     @Override
 179     public int getScreenHeight()
 180         throws HeadlessException {
 181         throw new HeadlessException();
 182     }
 183 
 184     @Override
 185     public int getScreenWidth()
 186         throws HeadlessException {
 187         throw new HeadlessException();
 188     }
 189 
 190     @Override
 191     public Dimension getScreenSize()
 192         throws HeadlessException {
 193         throw new HeadlessException();
 194     }
 195 
 196     @Override
 197     public Insets getScreenInsets(GraphicsConfiguration gc)
 198         throws HeadlessException {
 199         throw new HeadlessException();
 200     }
 201 
 202     @Override
 203     public void setDynamicLayout(boolean dynamic)
 204         throws HeadlessException {
 205         throw new HeadlessException();
 206     }
 207 
 208     @Override
 209     protected boolean isDynamicLayoutSet()
 210         throws HeadlessException {
 211         throw new HeadlessException();
 212     }
 213 
 214     @Override
 215     public boolean isDynamicLayoutActive()
 216         throws HeadlessException {
 217         throw new HeadlessException();
 218     }
 219 
 220     @Override
 221     public Clipboard getSystemClipboard()
 222         throws HeadlessException {
 223         throw new HeadlessException();
 224     }
 225 
 226     /*
 227      * Printing
 228      */
 229     @Override
 230     public PrintJob getPrintJob(Frame frame, String jobtitle,
 231         JobAttributes jobAttributes,
 232         PageAttributes pageAttributes) {
 233         if (frame != null) {
 234             // Should never happen
 235             throw new HeadlessException();
 236         }
 237         throw new IllegalArgumentException(
 238                 "PrintJob not supported in a headless environment");
 239     }
 240 
 241     @Override
 242     public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
 243     {
 244         if (frame != null) {
 245             // Should never happen
 246             throw new HeadlessException();
 247         }
 248         throw new IllegalArgumentException(
 249                 "PrintJob not supported in a headless environment");
 250     }
 251 
 252     /*
 253      * Headless toolkit - supported.
 254      */
 255 
 256     @Override
 257     public void sync() {
 258         // Do nothing
 259     }
 260 
 261     @Override
 262     protected boolean syncNativeQueue(final long timeout) {
 263         return false;
 264     }
 265 
 266     @Override
 267     public void beep() {
 268         // Send alert character
 269         System.out.write(0x07);
 270     }
 271 








 272     /*
 273      * Modality
 274      */
 275     @Override
 276     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 277         return false;
 278     }
 279 
 280     @Override
 281     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 282         return false;
 283     }
 284 
 285     @Override
 286     public boolean isDesktopSupported() {
 287         return false;
 288     }
 289 





 290     public boolean isWindowOpacityControlSupported() {
 291         return false;
 292     }
 293 
 294     @Override
 295     public boolean isWindowShapingSupported() {
 296         return false;
 297     }
 298 
 299     @Override
 300     public boolean isWindowTranslucencySupported() {
 301         return false;
 302     }
 303 
 304     @Override
 305     public  void grab(Window w) { }
 306 
 307     @Override
 308     public void ungrab(Window w) { }
 309 
 310     protected boolean syncNativeQueue() { return false; }
 311 
 312     @Override
 313     public InputMethodDescriptor getInputMethodAdapterDescriptor()
 314         throws AWTException
 315     {
 316         return (InputMethodDescriptor)null;
 317     }
 318 }