1 /* Toolkit.java -- AWT Toolkit superclass
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
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)
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
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
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. */
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;
80 import java.util.Properties;
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.
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.
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;
414 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
416 public void setDynamicLayout(boolean dynamic)
423 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
425 protected boolean isDynamicLayoutSet()
433 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
435 public boolean isDynamicLayoutActive()
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.
463 public Insets getScreenInsets(GraphicsConfiguration gc)
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.
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.
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()
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 " +
526 toolkit = (Toolkit) obj;
531 AWTError e = new AWTError("Cannot load AWT toolkit: " + toolkit_name);
532 throw (AWTError) e.initCause(t);
537 * Returns an image from the specified file, which must be in a
538 * recognized format. Supported formats vary from toolkit to toolkit.
540 * @return name The name of the file to read the image from.
542 public abstract Image getImage(String name);
545 * Returns an image from the specified URL, which must be in a
546 * recognized format. Supported formats vary from toolkit to toolkit.
548 * @return url The URl to read the image from.
550 public abstract Image getImage(URL url);
552 public abstract Image createImage(String filename);
554 public abstract Image createImage(URL url);
557 * Readies an image to be rendered on the screen. The width and height
558 * values can be set to the default sizes for the image by passing -1
559 * in those parameters.
561 * @param image The image to prepare for rendering.
562 * @param width The width of the image.
563 * @param height The height of the image.
564 * @param observer The observer to receive events about the preparation
567 * @return <code>true</code> if the image is already prepared for rendering,
568 * <code>false</code> otherwise.
570 public abstract boolean prepareImage(Image image, int width, int height,
571 ImageObserver observer);
574 * Checks the status of specified image as it is being readied for
577 * @param image The image to prepare for rendering.
578 * @param width The width of the image.
579 * @param height The height of the image.
580 * @param observer The observer to receive events about the preparation
583 * @return A union of the bitmasks from
584 * <code>java.awt.image.ImageObserver</code> that indicates the current
585 * state of the imaging readying process.
587 public abstract int checkImage(Image image, int width, int height,
588 ImageObserver observer);
591 * Creates an image using the specified <code>ImageProducer</code>
593 * @param producer The <code>ImageProducer</code> to create the image from.
595 * @return The created image.
597 public abstract Image createImage(ImageProducer producer);
600 * Creates an image from the specified byte array. The array must be in
601 * a recognized format. Supported formats vary from toolkit to toolkit.
603 * @param data The raw image data.
605 * @return The created image.
607 public Image createImage(byte[] data)
609 return createImage(data, 0, data.length);
613 * Creates an image from the specified portion of the byte array passed.
614 * The array must be in a recognized format. Supported formats vary from
615 * toolkit to toolkit.
617 * @param data The raw image data.
618 * @param offset The offset into the data where the image data starts.
619 * @param len The length of the image data.
621 * @return The created image.
623 public abstract Image createImage(byte[] data, int offset, int len);
626 * Returns a instance of <code>PrintJob</code> for the specified
629 * @param frame The window initiating the print job.
630 * @param title The print job title.
631 * @param props The print job properties.
633 * @return The requested print job, or <code>null</code> if the job
636 * @exception NullPointerException If frame is null,
637 * or GraphicsEnvironment.isHeadless() returns true.
638 * @exception SecurityException If this thread is not allowed to initiate
639 * a print job request.
641 public abstract PrintJob getPrintJob(Frame frame, String title,
645 * Returns a instance of <code>PrintJob</code> for the specified
648 * @param frame The window initiating the print job.
649 * @param title The print job title.
650 * @param jobAttr A set of job attributes which will control the print job.
651 * @param pageAttr A set of page attributes which will control the print job.
653 * @exception NullPointerException If frame is null, and either jobAttr is null
654 * or jobAttr.getDialog() returns JobAttributes.DialogType.NATIVE.
655 * @exception IllegalArgumentException If pageAttrspecifies differing cross
656 * feed and feed resolutions, or when GraphicsEnvironment.isHeadless() returns
658 * @exception SecurityException If this thread is not allowed to initiate
659 * a print job request.
663 public PrintJob getPrintJob(Frame frame, String title,
664 JobAttributes jobAttr, PageAttributes pageAttr)
670 * Causes a "beep" tone to be generated.
672 public abstract void beep();
675 * Returns the system clipboard.
677 * @return THe system clipboard.
679 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
681 public abstract Clipboard getSystemClipboard();
684 * Gets the singleton instance of the system selection as a Clipboard object.
686 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
690 public Clipboard getSystemSelection()
696 * Returns the accelerator key mask for menu shortcuts. The default is
697 * <code>Event.CTRL_MASK</code>. A toolkit must override this method
698 * to change the default.
700 * @return The key mask for the menu accelerator key.
702 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
704 public int getMenuShortcutKeyMask()
706 return Event.CTRL_MASK;
710 * Returns whether the given locking key on the keyboard is currently in its
713 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
714 * @exception IllegalArgumentException If keyCode is not one of the valid keys.
715 * @exception UnsupportedOperationException If the host system doesn't allow
716 * getting the state of this key programmatically, or if the keyboard doesn't
719 public boolean getLockingKeyState(int keyCode)
721 if (keyCode != KeyEvent.VK_CAPS_LOCK
722 && keyCode != KeyEvent.VK_NUM_LOCK
723 && keyCode != KeyEvent.VK_SCROLL_LOCK)
724 throw new IllegalArgumentException();
726 throw new UnsupportedOperationException();
730 * Sets the state of the given locking key on the keyboard.
732 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
733 * @exception IllegalArgumentException If keyCode is not one of the valid keys.
734 * @exception UnsupportedOperationException If the host system doesn't allow
735 * getting the state of this key programmatically, or if the keyboard doesn't
738 public void setLockingKeyState(int keyCode, boolean on)
740 if (keyCode != KeyEvent.VK_CAPS_LOCK
741 && keyCode != KeyEvent.VK_NUM_LOCK
742 && keyCode != KeyEvent.VK_SCROLL_LOCK)
743 throw new IllegalArgumentException();
745 throw new UnsupportedOperationException();
749 * Returns the native container object of the specified component. This
750 * method is necessary because the parent component might be a lightweight
753 * @param component The component to fetch the native container for.
755 * @return The native container object for this component.
757 protected static Container getNativeContainer(Component component)
759 component = component.getParent();
762 if (component == null)
764 if (! (component instanceof Container))
766 component = component.getParent();
769 if (component.getPeer() instanceof LightweightPeer)
771 component = component.getParent();
774 return (Container) component;
779 * Creates a new custom cursor object.
781 * @exception IndexOutOfBoundsException If the hotSpot values are outside
782 * the bounds of the cursor.
783 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
785 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
787 // Presumably the only reason this isn't abstract is for backwards
788 // compatibility? FIXME?
793 * Returns the supported cursor dimension which is closest to the
796 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
798 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
800 return new Dimension (0,0);
804 * Returns the maximum number of colors the Toolkit supports in a custom
807 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
809 public int getMaximumCursorColors()
815 * Returns whether Toolkit supports this state for Frames.
817 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
821 public boolean isFrameStateSupported(int state)
827 * Returns the value of the property with the specified name, or the
828 * default value if the property does not exist.
830 * @param key The name of the property to retrieve.
831 * @param def The default value of the property.
833 public static String getProperty(String key, String def)
835 return props.getProperty(key, def);
840 * Returns the event queue that is suitable for the calling context.
842 * <p>Despite the word “System” in the name of this
843 * method, a toolkit may provide different event queues for each
844 * applet. There is no guarantee that the same queue is shared
847 * <p>The implementation first checks whether a
848 * SecurityManager has been installed. If so, its {@link
849 * java.lang.SecurityManager#checkAwtEventQueueAccess()} method gets
850 * called. The security manager will throw a SecurityException if it
851 * does not grant the permission to access the event queue.
853 * <p>Next, the call is delegated to {@link
854 * #getSystemEventQueueImpl()}.
856 * @return The event queue for this applet (or application).
858 * @throws SecurityException if a security manager has been
859 * installed, and it does not grant the permission to access the
862 public final EventQueue getSystemEventQueue()
866 sm = System.getSecurityManager();
868 sm.checkAwtEventQueueAccess();
870 return getSystemEventQueueImpl();
875 * Returns the event queue that is suitable for the calling context.
877 * <p>Despite the word “System” in the name of this
878 * method, a toolkit may provide different event queues for each
879 * applet. There is no guarantee that the same queue is shared
882 * <p>No security checks are performed, which is why this method
883 * may only be called by Toolkits.
885 * @see #getSystemEventQueue()
887 protected abstract EventQueue getSystemEventQueueImpl();
893 public abstract DragSourceContextPeer
894 createDragSourceContextPeer(DragGestureEvent e);
899 public DragGestureRecognizer
900 createDragGestureRecognizer(Class recognizer, DragSource ds,
901 Component comp, int actions,
902 DragGestureListener l)
907 public final Object getDesktopProperty(String propertyName)
909 return desktopProperties.get(propertyName);
912 protected final void setDesktopProperty(String name, Object newValue)
914 Object oldValue = getDesktopProperty(name);
915 desktopProperties.put(name, newValue);
916 desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
919 protected Object lazilyLoadDesktopProperty(String name)
921 // FIXME - what is this??
925 protected void initializeDesktopProperties()
927 // Overridden by toolkit implementation?
930 public void addPropertyChangeListener(String name,
931 PropertyChangeListener pcl)
933 desktopPropsSupport.addPropertyChangeListener(name, pcl);
936 public void removePropertyChangeListener(String name,
937 PropertyChangeListener pcl)
939 desktopPropsSupport.removePropertyChangeListener(name, pcl);
945 public PropertyChangeListener[] getPropertyChangeListeners()
947 return desktopPropsSupport.getPropertyChangeListeners();
953 public PropertyChangeListener[] getPropertyChangeListeners(String name)
955 return desktopPropsSupport.getPropertyChangeListeners(name);
958 public void addAWTEventListener(AWTEventListener listener, long eventMask)
960 // SecurityManager s = System.getSecurityManager();
962 // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
966 public void removeAWTEventListener(AWTEventListener listener)
974 public AWTEventListener[] getAWTEventListeners()
982 public AWTEventListener[] getAWTEventListeners(long mask)
990 public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);