Merge from the pain train
[official-gcc.git] / libjava / java / awt / Toolkit.java
blobc7f2de956202984a8924d8699e7c3abd10d7d5fe
1 /* Toolkit.java -- AWT Toolkit superclass
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
5 This file is part of GNU Classpath.
7 GNU Classpath is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Classpath is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Classpath; see the file COPYING. If not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA.
22 Linking this library statically or dynamically with other modules is
23 making a combined work based on this library. Thus, the terms and
24 conditions of the GNU General Public License cover the whole
25 combination.
27 As a special exception, the copyright holders of this library give you
28 permission to link this library with independent modules to produce an
29 executable, regardless of the license terms of these independent
30 modules, and to copy and distribute the resulting executable under
31 terms of your choice, provided that you also meet, for each linked
32 independent module, the terms and conditions of the license of that
33 module. An independent module is a module which is not derived from
34 or based on this library. If you modify this library, you may extend
35 this exception to your version of the library, but you are not
36 obligated to do so. If you do not wish to do so, delete this
37 exception statement from your version. */
40 package java.awt;
42 import java.awt.datatransfer.Clipboard;
43 import java.awt.dnd.DragGestureEvent;
44 import java.awt.dnd.DragGestureListener;
45 import java.awt.dnd.DragGestureRecognizer;
46 import java.awt.dnd.DragSource;
47 import java.awt.dnd.peer.DragSourceContextPeer;
48 import java.awt.event.AWTEventListener;
49 import java.awt.event.KeyEvent;
50 import java.awt.im.InputMethodHighlight;
51 import java.awt.image.ColorModel;
52 import java.awt.image.ImageObserver;
53 import java.awt.image.ImageProducer;
54 import java.awt.peer.ButtonPeer;
55 import java.awt.peer.CanvasPeer;
56 import java.awt.peer.CheckboxMenuItemPeer;
57 import java.awt.peer.CheckboxPeer;
58 import java.awt.peer.ChoicePeer;
59 import java.awt.peer.DialogPeer;
60 import java.awt.peer.FileDialogPeer;
61 import java.awt.peer.FontPeer;
62 import java.awt.peer.FramePeer;
63 import java.awt.peer.LabelPeer;
64 import java.awt.peer.LightweightPeer;
65 import java.awt.peer.ListPeer;
66 import java.awt.peer.MenuBarPeer;
67 import java.awt.peer.MenuItemPeer;
68 import java.awt.peer.MenuPeer;
69 import java.awt.peer.PanelPeer;
70 import java.awt.peer.PopupMenuPeer;
71 import java.awt.peer.ScrollPanePeer;
72 import java.awt.peer.ScrollbarPeer;
73 import java.awt.peer.TextAreaPeer;
74 import java.awt.peer.TextFieldPeer;
75 import java.awt.peer.WindowPeer;
76 import java.beans.PropertyChangeListener;
77 import java.beans.PropertyChangeSupport;
78 import java.net.URL;
79 import java.util.Map;
80 import java.util.Properties;
82 /**
83 * The AWT system uses a set of native peer objects to implement its
84 * widgets. These peers are provided by a peer toolkit, that is accessed
85 * via a subclass of this superclass. The system toolkit is retrieved
86 * by the static methods <code>getDefaultToolkit</code>. This method
87 * determines the system toolkit by examining the system property
88 * <code>awt.toolkit</code>. That property is set to the name of the
89 * <code>Toolkit</code> subclass for the specified peer set. If the
90 * <code>awt.toolkit</code> property is not set, then the default
91 * toolkit <code>gnu.java.awt.peer.gtk.GtkToolkit</code> is used. This
92 * toolkit creates its peers using the GTK+ toolkit.
94 * @author Aaron M. Renn (arenn@urbanophile.com)
96 public abstract class Toolkit
98 /** The default toolkit name. */
99 private static String default_toolkit_name
100 = gnu.classpath.Configuration.default_awt_peer_toolkit;
103 * The toolkit in use. Once we load it, we don't ever change it
104 * if the awt.toolkit property is set.
106 private static Toolkit toolkit;
108 /** The toolkit properties. */
109 private static Properties props = new Properties();
111 protected final Map desktopProperties = new Properties();
113 protected final PropertyChangeSupport desktopPropsSupport
114 = new PropertyChangeSupport(this);
117 * Default constructor for subclasses.
119 public Toolkit()
124 * Creates a peer object for the specified <code>Button</code>.
126 * @param target The <code>Button</code> to create the peer for.
128 * @return The peer for the specified <code>Button</code> object.
130 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
132 protected abstract ButtonPeer createButton(Button target);
135 * Creates a peer object for the specified <code>TextField</code>.
137 * @param target The <code>TextField</code> to create the peer for.
139 * @return The peer for the specified <code>TextField</code> object.
141 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
143 protected abstract TextFieldPeer createTextField(TextField target);
146 * Creates a peer object for the specified <code>Label</code>.
148 * @param target The <code>Label</code> to create the peer for.
150 * @return The peer for the specified <code>Label</code> object.
152 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
154 protected abstract LabelPeer createLabel(Label target);
157 * Creates a peer object for the specified <code>List</code>.
159 * @param target The <code>List</code> to create the peer for.
161 * @return The peer for the specified <code>List</code> object.
163 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
165 protected abstract ListPeer createList(List target);
168 * Creates a peer object for the specified <code>Checkbox</code>.
170 * @param target The <code>Checkbox</code> to create the peer for.
172 * @return The peer for the specified <code>Checkbox</code> object.
174 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
176 protected abstract CheckboxPeer createCheckbox(Checkbox target);
179 * Creates a peer object for the specified <code>Scrollbar</code>.
181 * @param target The <code>Scrollbar</code> to create the peer for.
183 * @return The peer for the specified <code>Scrollbar</code> object.
185 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
187 protected abstract ScrollbarPeer createScrollbar(Scrollbar target);
190 * Creates a peer object for the specified <code>ScrollPane</code>.
192 * @param target The <code>ScrollPane</code> to create the peer for.
194 * @return The peer for the specified <code>ScrollPane</code> object.
196 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
198 protected abstract ScrollPanePeer createScrollPane(ScrollPane target);
201 * Creates a peer object for the specified <code>TextArea</code>.
203 * @param target The <code>TextArea</code> to create the peer for.
205 * @return The peer for the specified <code>TextArea</code> object.
207 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
209 protected abstract TextAreaPeer createTextArea(TextArea target);
212 * Creates a peer object for the specified <code>Choice</code>.
214 * @param target The <code>Choice</code> to create the peer for.
216 * @return The peer for the specified <code>Choice</code> object.
218 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
220 protected abstract ChoicePeer createChoice(Choice target);
223 * Creates a peer object for the specified <code>Frame</code>.
225 * @param target The <code>Frame</code> to create the peer for.
227 * @return The peer for the specified <code>Frame</code> object.
229 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
231 protected abstract FramePeer createFrame(Frame target);
234 * Creates a peer object for the specified <code>Canvas</code>.
236 * @param target The <code>Canvas</code> to create the peer for.
238 * @return The peer for the specified <code>Canvas</code> object.
240 protected abstract CanvasPeer createCanvas(Canvas target);
243 * Creates a peer object for the specified <code>Panel</code>.
245 * @param target The <code>Panel</code> to create the peer for.
247 * @return The peer for the specified <code>Panel</code> object.
249 protected abstract PanelPeer createPanel(Panel target);
252 * Creates a peer object for the specified <code>Window</code>.
254 * @param target The <code>Window</code> to create the peer for.
256 * @return The peer for the specified <code>Window</code> object.
258 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
260 protected abstract WindowPeer createWindow(Window target);
263 * Creates a peer object for the specified <code>Dialog</code>.
265 * @param target The dialog to create the peer for
267 * @return The peer for the specified font name.
269 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
271 protected abstract DialogPeer createDialog(Dialog target);
274 * Creates a peer object for the specified <code>MenuBar</code>.
276 * @param target The <code>MenuBar</code> to create the peer for.
278 * @return The peer for the specified <code>MenuBar</code> object.
280 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
282 protected abstract MenuBarPeer createMenuBar(MenuBar target);
285 * Creates a peer object for the specified <code>Menu</code>.
287 * @param target The <code>Menu</code> to create the peer for.
289 * @return The peer for the specified <code>Menu</code> object.
291 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
293 protected abstract MenuPeer createMenu(Menu target);
296 * Creates a peer object for the specified <code>PopupMenu</code>.
298 * @param target The <code>PopupMenu</code> to create the peer for.
300 * @return The peer for the specified <code>PopupMenu</code> object.
302 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
304 protected abstract PopupMenuPeer createPopupMenu(PopupMenu target);
307 * Creates a peer object for the specified <code>MenuItem</code>.
309 * @param target The <code>MenuItem</code> to create the peer for.
311 * @return The peer for the specified <code>MenuItem</code> object.
313 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
315 protected abstract MenuItemPeer createMenuItem(MenuItem target);
318 * Creates a peer object for the specified <code>FileDialog</code>.
320 * @param target The <code>FileDialog</code> to create the peer for.
322 * @return The peer for the specified <code>FileDialog</code> object.
324 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
326 protected abstract FileDialogPeer createFileDialog(FileDialog target);
329 * Creates a peer object for the specified <code>CheckboxMenuItem</code>.
331 * @param target The <code>CheckboxMenuItem</code> to create the peer for.
333 * @return The peer for the specified <code>CheckboxMenuItem</code> object.
335 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
337 protected abstract CheckboxMenuItemPeer
338 createCheckboxMenuItem(CheckboxMenuItem target);
341 * Creates a peer object for the specified <code>Component</code>. The
342 * peer returned by this method is not a native windowing system peer
343 * with its own native window. Instead, this method allows the component
344 * to draw on its parent window as a "lightweight" widget.
346 * @param target The <code>Component</code> to create the peer for.
348 * @return The peer for the specified <code>Component</code> object.
350 protected LightweightPeer createComponent(Component target)
352 return new gnu.java.awt.peer.GLightweightPeer (target);
356 * Creates a peer object for the specified font name.
358 * @param name The font to create the peer for.
359 * @param style The font style to create the peer for.
361 * @return The peer for the specified font name.
363 * @deprecated
365 protected abstract FontPeer getFontPeer(String name, int style);
368 * Copies the current system colors into the specified array. This is
369 * the interface used by the <code>SystemColor</code> class. Although
370 * this method fills in the array with some default colors a real Toolkit
371 * should override this method and provide real system colors for the
372 * native GUI platform.
374 * @param systemColors The array to copy the system colors into.
375 * It must be at least 26 elements.
377 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
379 * @see java.awt.SystemColor
381 protected void loadSystemColors(int systemColors[])
383 systemColors[SystemColor.DESKTOP] = 0xFF005C5C;
384 systemColors[SystemColor.ACTIVE_CAPTION] = 0xFF000080;
385 systemColors[SystemColor.ACTIVE_CAPTION_TEXT] = 0xFFFFFFFF;
386 systemColors[SystemColor.ACTIVE_CAPTION_BORDER] = 0xFFC0C0C0;
387 systemColors[SystemColor.INACTIVE_CAPTION] = 0xFF808080;
388 systemColors[SystemColor.INACTIVE_CAPTION_TEXT] = 0xFFC0C0C0;
389 systemColors[SystemColor.INACTIVE_CAPTION_BORDER] = 0xFFC0C0C0;
390 systemColors[SystemColor.WINDOW] = 0xFFFFFFFF;
391 systemColors[SystemColor.WINDOW_BORDER] = 0xFF000000;
392 systemColors[SystemColor.WINDOW_TEXT] = 0xFF000000;
393 systemColors[SystemColor.MENU] = 0xFFC0C0C0;
394 systemColors[SystemColor.MENU_TEXT] = 0xFF000000;
395 systemColors[SystemColor.TEXT] = 0xFFC0C0C0;
396 systemColors[SystemColor.TEXT_TEXT] = 0xFF000000;
397 systemColors[SystemColor.TEXT_HIGHLIGHT] = 0xFF000090;
398 systemColors[SystemColor.TEXT_HIGHLIGHT_TEXT] = 0xFFFFFFFF;
399 systemColors[SystemColor.TEXT_INACTIVE_TEXT] = 0xFF808080;
400 systemColors[SystemColor.CONTROL] = 0xFFC0C0C0;
401 systemColors[SystemColor.CONTROL_TEXT] = 0xFF000000;
402 systemColors[SystemColor.CONTROL_HIGHLIGHT] = 0xFFFFFFFF;
403 systemColors[SystemColor.CONTROL_LT_HIGHLIGHT] = 0xFFE0E0E0;
404 systemColors[SystemColor.CONTROL_SHADOW] = 0xFF808080;
405 systemColors[SystemColor.CONTROL_DK_SHADOW] = 0xFF000000;
406 systemColors[SystemColor.SCROLLBAR] = 0xFFE0E0E0;
407 systemColors[SystemColor.INFO] = 0xFFE0E000;
408 systemColors[SystemColor.INFO_TEXT] = 0xFF000000;
412 * @since 1.4
414 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
416 public void setDynamicLayout(boolean dynamic)
421 * @since 1.4
423 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
425 protected boolean isDynamicLayoutSet()
427 return false;
431 * @since 1.4
433 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
435 public boolean isDynamicLayoutActive()
437 return false;
441 * Returns the dimensions of the screen in pixels.
443 * @return The dimensions of the screen in pixels.
445 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
447 public abstract Dimension getScreenSize();
450 * Returns the screen resolution in dots per square inch.
452 * @return The screen resolution in dots per square inch.
454 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
456 public abstract int getScreenResolution();
459 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
461 * @since 1.4
463 public Insets getScreenInsets(GraphicsConfiguration gc)
465 return null;
469 * Returns the color model of the screen.
471 * @return The color model of the screen.
473 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
475 public abstract ColorModel getColorModel();
478 * Returns the names of the available fonts.
480 * @return The names of the available fonts.
482 * @deprecated
484 public abstract String[] getFontList();
487 * Return the font metrics for the specified font
489 * @param name The name of the font to return metrics for.
491 * @return The requested font metrics.
493 * @deprecated
495 public abstract FontMetrics getFontMetrics(Font name);
498 * Flushes any buffered data to the screen so that it is in sync with
499 * what the AWT system has drawn to it.
501 public abstract void sync();
504 * Returns an instance of the default toolkit. The default toolkit is
505 * the subclass of <code>Toolkit</code> specified in the system property
506 * <code>awt.toolkit</code>, or <code>gnu.java.awt.peer.gtk.GtkToolkit</code>
507 * if the property is not set.
509 * @return An instance of the system default toolkit.
511 * @throws AWTError If the toolkit cannot be loaded.
513 public static Toolkit getDefaultToolkit()
515 if (toolkit != null)
516 return toolkit;
517 String toolkit_name = System.getProperty("awt.toolkit",
518 default_toolkit_name);
521 Class cls = Class.forName(toolkit_name);
522 Object obj = cls.newInstance();
523 if (!(obj instanceof Toolkit))
524 throw new AWTError(toolkit_name + " is not a subclass of " +
525 "java.awt.Toolkit");
526 toolkit = (Toolkit) obj;
527 return toolkit;
529 catch (ThreadDeath death)
531 throw death;
533 catch (Throwable t)
535 AWTError e = new AWTError("Cannot load AWT toolkit: " + toolkit_name);
536 throw (AWTError) e.initCause(t);
541 * Returns an image from the specified file, which must be in a
542 * recognized format. Supported formats vary from toolkit to toolkit.
544 * @return name The name of the file to read the image from.
546 public abstract Image getImage(String name);
549 * Returns an image from the specified URL, which must be in a
550 * recognized format. Supported formats vary from toolkit to toolkit.
552 * @return url The URl to read the image from.
554 public abstract Image getImage(URL url);
556 public abstract Image createImage(String filename);
558 public abstract Image createImage(URL url);
561 * Readies an image to be rendered on the screen. The width and height
562 * values can be set to the default sizes for the image by passing -1
563 * in those parameters.
565 * @param image The image to prepare for rendering.
566 * @param width The width of the image.
567 * @param height The height of the image.
568 * @param observer The observer to receive events about the preparation
569 * process.
571 * @return <code>true</code> if the image is already prepared for rendering,
572 * <code>false</code> otherwise.
574 public abstract boolean prepareImage(Image image, int width, int height,
575 ImageObserver observer);
578 * Checks the status of specified image as it is being readied for
579 * rendering.
581 * @param image The image to prepare for rendering.
582 * @param width The width of the image.
583 * @param height The height of the image.
584 * @param observer The observer to receive events about the preparation
585 * process.
587 * @return A union of the bitmasks from
588 * <code>java.awt.image.ImageObserver</code> that indicates the current
589 * state of the imaging readying process.
591 public abstract int checkImage(Image image, int width, int height,
592 ImageObserver observer);
595 * Creates an image using the specified <code>ImageProducer</code>
597 * @param producer The <code>ImageProducer</code> to create the image from.
599 * @return The created image.
601 public abstract Image createImage(ImageProducer producer);
604 * Creates an image from the specified byte array. The array must be in
605 * a recognized format. Supported formats vary from toolkit to toolkit.
607 * @param data The raw image data.
609 * @return The created image.
611 public Image createImage(byte[] data)
613 return createImage(data, 0, data.length);
617 * Creates an image from the specified portion of the byte array passed.
618 * The array must be in a recognized format. Supported formats vary from
619 * toolkit to toolkit.
621 * @param data The raw image data.
622 * @param offset The offset into the data where the image data starts.
623 * @param len The length of the image data.
625 * @return The created image.
627 public abstract Image createImage(byte[] data, int offset, int len);
630 * Returns a instance of <code>PrintJob</code> for the specified
631 * arguments.
633 * @param frame The window initiating the print job.
634 * @param title The print job title.
635 * @param props The print job properties.
637 * @return The requested print job, or <code>null</code> if the job
638 * was cancelled.
640 * @exception NullPointerException If frame is null,
641 * or GraphicsEnvironment.isHeadless() returns true.
642 * @exception SecurityException If this thread is not allowed to initiate
643 * a print job request.
645 public abstract PrintJob getPrintJob(Frame frame, String title,
646 Properties props);
649 * Returns a instance of <code>PrintJob</code> for the specified
650 * arguments.
652 * @param frame The window initiating the print job.
653 * @param title The print job title.
654 * @param jobAttr A set of job attributes which will control the print job.
655 * @param pageAttr A set of page attributes which will control the print job.
657 * @exception NullPointerException If frame is null, and either jobAttr is null
658 * or jobAttr.getDialog() returns JobAttributes.DialogType.NATIVE.
659 * @exception IllegalArgumentException If pageAttrspecifies differing cross
660 * feed and feed resolutions, or when GraphicsEnvironment.isHeadless() returns
661 * true.
662 * @exception SecurityException If this thread is not allowed to initiate
663 * a print job request.
665 * @since 1.3
667 public PrintJob getPrintJob(Frame frame, String title,
668 JobAttributes jobAttr, PageAttributes pageAttr)
670 return null;
674 * Causes a "beep" tone to be generated.
676 public abstract void beep();
679 * Returns the system clipboard.
681 * @return THe system clipboard.
683 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
685 public abstract Clipboard getSystemClipboard();
688 * Gets the singleton instance of the system selection as a Clipboard object.
690 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
692 * @since 1.4
694 public Clipboard getSystemSelection()
696 return null;
700 * Returns the accelerator key mask for menu shortcuts. The default is
701 * <code>Event.CTRL_MASK</code>. A toolkit must override this method
702 * to change the default.
704 * @return The key mask for the menu accelerator key.
706 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
708 public int getMenuShortcutKeyMask()
710 return Event.CTRL_MASK;
714 * Returns whether the given locking key on the keyboard is currently in its
715 * "on" state.
717 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
718 * @exception IllegalArgumentException If keyCode is not one of the valid keys.
719 * @exception UnsupportedOperationException If the host system doesn't allow
720 * getting the state of this key programmatically, or if the keyboard doesn't
721 * have this key.
723 public boolean getLockingKeyState(int keyCode)
725 if (keyCode != KeyEvent.VK_CAPS_LOCK
726 && keyCode != KeyEvent.VK_NUM_LOCK
727 && keyCode != KeyEvent.VK_SCROLL_LOCK)
728 throw new IllegalArgumentException();
730 throw new UnsupportedOperationException();
734 * Sets the state of the given locking key on the keyboard.
736 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
737 * @exception IllegalArgumentException If keyCode is not one of the valid keys.
738 * @exception UnsupportedOperationException If the host system doesn't allow
739 * getting the state of this key programmatically, or if the keyboard doesn't
740 * have this key.
742 public void setLockingKeyState(int keyCode, boolean on)
744 if (keyCode != KeyEvent.VK_CAPS_LOCK
745 && keyCode != KeyEvent.VK_NUM_LOCK
746 && keyCode != KeyEvent.VK_SCROLL_LOCK)
747 throw new IllegalArgumentException();
749 throw new UnsupportedOperationException();
753 * Returns the native container object of the specified component. This
754 * method is necessary because the parent component might be a lightweight
755 * component.
757 * @param component The component to fetch the native container for.
759 * @return The native container object for this component.
761 protected static Container getNativeContainer(Component component)
763 component = component.getParent();
764 while (true)
766 if (component == null)
767 return null;
768 if (! (component instanceof Container))
770 component = component.getParent();
771 continue;
773 if (component.getPeer() instanceof LightweightPeer)
775 component = component.getParent();
776 continue;
778 return (Container) component;
783 * Creates a new custom cursor object.
785 * @exception IndexOutOfBoundsException If the hotSpot values are outside
786 * the bounds of the cursor.
787 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
789 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
791 // Presumably the only reason this isn't abstract is for backwards
792 // compatibility? FIXME?
793 return null;
797 * Returns the supported cursor dimension which is closest to the
798 * desired sizes.
800 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
802 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
804 return new Dimension (0,0);
808 * Returns the maximum number of colors the Toolkit supports in a custom
809 * cursor palette.
811 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
813 public int getMaximumCursorColors()
815 return 0;
819 * Returns whether Toolkit supports this state for Frames.
821 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
823 * @since 1.4
825 public boolean isFrameStateSupported(int state)
827 return false;
831 * Returns the value of the property with the specified name, or the
832 * default value if the property does not exist.
834 * @param key The name of the property to retrieve.
835 * @param def The default value of the property.
837 public static String getProperty(String key, String def)
839 return props.getProperty(key, def);
844 * Returns the event queue that is suitable for the calling context.
846 * <p>Despite the word &#x201c;System&#x201d; in the name of this
847 * method, a toolkit may provide different event queues for each
848 * applet. There is no guarantee that the same queue is shared
849 * system-wide.
851 * <p>The implementation first checks whether a
852 * SecurityManager has been installed. If so, its {@link
853 * java.lang.SecurityManager#checkAwtEventQueueAccess()} method gets
854 * called. The security manager will throw a SecurityException if it
855 * does not grant the permission to access the event queue.
857 * <p>Next, the call is delegated to {@link
858 * #getSystemEventQueueImpl()}.
860 * @return The event queue for this applet (or application).
862 * @throws SecurityException if a security manager has been
863 * installed, and it does not grant the permission to access the
864 * event queue.
866 public final EventQueue getSystemEventQueue()
868 SecurityManager sm;
870 sm = System.getSecurityManager();
871 if (sm != null)
872 sm.checkAwtEventQueueAccess();
874 return getSystemEventQueueImpl();
879 * Returns the event queue that is suitable for the calling context.
881 * <p>Despite the word &#x201c;System&#x201d; in the name of this
882 * method, a toolkit may provide different event queues for each
883 * applet. There is no guarantee that the same queue is shared
884 * system-wide.
886 * <p>No security checks are performed, which is why this method
887 * may only be called by Toolkits.
889 * @see #getSystemEventQueue()
891 protected abstract EventQueue getSystemEventQueueImpl();
895 * @since 1.3
897 public abstract DragSourceContextPeer
898 createDragSourceContextPeer(DragGestureEvent e);
901 * @since 1.3
903 public DragGestureRecognizer
904 createDragGestureRecognizer(Class recognizer, DragSource ds,
905 Component comp, int actions,
906 DragGestureListener l)
908 return null;
911 public final Object getDesktopProperty(String propertyName)
913 return desktopProperties.get(propertyName);
916 protected final void setDesktopProperty(String name, Object newValue)
918 Object oldValue = getDesktopProperty(name);
919 desktopProperties.put(name, newValue);
920 desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
923 protected Object lazilyLoadDesktopProperty(String name)
925 // FIXME - what is this??
926 return null;
929 protected void initializeDesktopProperties()
931 // Overridden by toolkit implementation?
934 public void addPropertyChangeListener(String name,
935 PropertyChangeListener pcl)
937 desktopPropsSupport.addPropertyChangeListener(name, pcl);
940 public void removePropertyChangeListener(String name,
941 PropertyChangeListener pcl)
943 desktopPropsSupport.removePropertyChangeListener(name, pcl);
947 * @since 1.4
949 public PropertyChangeListener[] getPropertyChangeListeners()
951 return desktopPropsSupport.getPropertyChangeListeners();
955 * @since 1.4
957 public PropertyChangeListener[] getPropertyChangeListeners(String name)
959 return desktopPropsSupport.getPropertyChangeListeners(name);
962 public void addAWTEventListener(AWTEventListener listener, long eventMask)
964 // SecurityManager s = System.getSecurityManager();
965 // if (s != null)
966 // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
967 // FIXME
970 public void removeAWTEventListener(AWTEventListener listener)
972 // FIXME
976 * @since 1.4
978 public AWTEventListener[] getAWTEventListeners()
980 return null;
984 * @since 1.4
986 public AWTEventListener[] getAWTEventListeners(long mask)
988 return null;
992 * @since 1.3
994 public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
995 } // class Toolkit