src/java.desktop/share/classes/java/awt/Toolkit.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 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 java.awt;
  27 
  28 import java.beans.PropertyChangeEvent;



  29 import java.awt.event.*;
  30 import java.awt.peer.*;
  31 import java.awt.im.InputMethodHighlight;

  32 import java.awt.image.ImageObserver;
  33 import java.awt.image.ImageProducer;
  34 import java.awt.image.ColorModel;
  35 import java.awt.datatransfer.Clipboard;
  36 import java.awt.dnd.DragSource;
  37 import java.awt.dnd.DragGestureRecognizer;
  38 import java.awt.dnd.DragGestureEvent;
  39 import java.awt.dnd.DragGestureListener;
  40 import java.awt.dnd.InvalidDnDOperationException;
  41 import java.awt.dnd.peer.DragSourceContextPeer;
  42 import java.net.URL;
  43 import java.io.File;
  44 import java.io.FileInputStream;










  45 
  46 import java.util.*;
  47 import java.beans.PropertyChangeListener;
  48 import java.beans.PropertyChangeSupport;
  49 import sun.awt.AppContext;
  50 
  51 import sun.awt.HeadlessToolkit;
  52 import sun.awt.NullComponentPeer;
  53 import sun.awt.PeerEvent;
  54 import sun.awt.SunToolkit;
  55 import sun.awt.AWTAccessor;
  56 import sun.awt.AWTPermissions;
  57 
  58 import sun.util.CoreResourceBundleControl;
  59 
  60 /**
  61  * This class is the abstract superclass of all actual
  62  * implementations of the Abstract Window Toolkit. Subclasses of
  63  * the <code>Toolkit</code> class are used to bind the various components
  64  * to particular native toolkit implementations.
  65  * <p>
  66  * Many GUI events may be delivered to user
  67  * asynchronously, if the opposite is not specified explicitly.
  68  * As well as
  69  * many GUI operations may be performed asynchronously.
  70  * This fact means that if the state of a component is set, and then
  71  * the state immediately queried, the returned value may not yet
  72  * reflect the requested change.  This behavior includes, but is not
  73  * limited to:
  74  * <ul>
  75  * <li>Scrolling to a specified position.
  76  * <br>For example, calling <code>ScrollPane.setScrollPosition</code>
  77  *     and then <code>getScrollPosition</code> may return an incorrect


  95  *     <code>Frame</code> or <code>Dialog</code> are forwarded
  96  *     to the underlying window management system and may be
  97  *     ignored or modified.  See {@link java.awt.Window} for
  98  *     more information.
  99  * </ul>
 100  * <p>
 101  * Most applications should not call any of the methods in this
 102  * class directly. The methods defined by <code>Toolkit</code> are
 103  * the "glue" that joins the platform-independent classes in the
 104  * <code>java.awt</code> package with their counterparts in
 105  * <code>java.awt.peer</code>. Some methods defined by
 106  * <code>Toolkit</code> query the native operating system directly.
 107  *
 108  * @author      Sami Shaio
 109  * @author      Arthur van Hoff
 110  * @author      Fred Ecks
 111  * @since       1.0
 112  */
 113 public abstract class Toolkit {
 114 
 115     /**
 116      * Creates this toolkit's implementation of the <code>Desktop</code>
 117      * using the specified peer interface.
 118      * @param     target the desktop to be implemented
 119      * @return    this toolkit's implementation of the <code>Desktop</code>
 120      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 121      * returns true
 122      * @see       java.awt.GraphicsEnvironment#isHeadless
 123      * @see       java.awt.Desktop
 124      * @see       java.awt.peer.DesktopPeer
 125      * @since 1.6
 126      */
 127     protected abstract DesktopPeer createDesktopPeer(Desktop target)
 128       throws HeadlessException;
 129 
 130 
 131     /**
 132      * Creates this toolkit's implementation of <code>Button</code> using
 133      * the specified peer interface.
 134      * @param     target the button to be implemented.
 135      * @return    this toolkit's implementation of <code>Button</code>.
 136      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 137      * returns true
 138      * @see       java.awt.GraphicsEnvironment#isHeadless
 139      * @see       java.awt.Button
 140      * @see       java.awt.peer.ButtonPeer
 141      */
 142     protected abstract ButtonPeer createButton(Button target)
 143         throws HeadlessException;
 144 
 145     /**
 146      * Creates this toolkit's implementation of <code>TextField</code> using
 147      * the specified peer interface.
 148      * @param     target the text field to be implemented.
 149      * @return    this toolkit's implementation of <code>TextField</code>.
 150      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 151      * returns true
 152      * @see       java.awt.GraphicsEnvironment#isHeadless
 153      * @see       java.awt.TextField
 154      * @see       java.awt.peer.TextFieldPeer
 155      */
 156     protected abstract TextFieldPeer createTextField(TextField target)
 157         throws HeadlessException;
 158 
 159     /**
 160      * Creates this toolkit's implementation of <code>Label</code> using
 161      * the specified peer interface.
 162      * @param     target the label to be implemented.
 163      * @return    this toolkit's implementation of <code>Label</code>.
 164      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 165      * returns true
 166      * @see       java.awt.GraphicsEnvironment#isHeadless
 167      * @see       java.awt.Label
 168      * @see       java.awt.peer.LabelPeer
 169      */
 170     protected abstract LabelPeer createLabel(Label target)
 171         throws HeadlessException;
 172 
 173     /**
 174      * Creates this toolkit's implementation of <code>List</code> using
 175      * the specified peer interface.
 176      * @param     target the list to be implemented.
 177      * @return    this toolkit's implementation of <code>List</code>.
 178      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 179      * returns true
 180      * @see       java.awt.GraphicsEnvironment#isHeadless
 181      * @see       java.awt.List
 182      * @see       java.awt.peer.ListPeer
 183      */
 184     protected abstract ListPeer createList(java.awt.List target)
 185         throws HeadlessException;
 186 
 187     /**
 188      * Creates this toolkit's implementation of <code>Checkbox</code> using
 189      * the specified peer interface.
 190      * @param     target the check box to be implemented.
 191      * @return    this toolkit's implementation of <code>Checkbox</code>.
 192      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 193      * returns true
 194      * @see       java.awt.GraphicsEnvironment#isHeadless
 195      * @see       java.awt.Checkbox
 196      * @see       java.awt.peer.CheckboxPeer
 197      */
 198     protected abstract CheckboxPeer createCheckbox(Checkbox target)
 199         throws HeadlessException;
 200 
 201     /**
 202      * Creates this toolkit's implementation of <code>Scrollbar</code> using
 203      * the specified peer interface.
 204      * @param     target the scroll bar to be implemented.
 205      * @return    this toolkit's implementation of <code>Scrollbar</code>.
 206      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 207      * returns true
 208      * @see       java.awt.GraphicsEnvironment#isHeadless
 209      * @see       java.awt.Scrollbar
 210      * @see       java.awt.peer.ScrollbarPeer
 211      */
 212     protected abstract ScrollbarPeer createScrollbar(Scrollbar target)
 213         throws HeadlessException;
 214 
 215     /**
 216      * Creates this toolkit's implementation of <code>ScrollPane</code> using
 217      * the specified peer interface.
 218      * @param     target the scroll pane to be implemented.
 219      * @return    this toolkit's implementation of <code>ScrollPane</code>.
 220      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 221      * returns true
 222      * @see       java.awt.GraphicsEnvironment#isHeadless
 223      * @see       java.awt.ScrollPane
 224      * @see       java.awt.peer.ScrollPanePeer
 225      * @since     1.1
 226      */
 227     protected abstract ScrollPanePeer createScrollPane(ScrollPane target)
 228         throws HeadlessException;
 229 
 230     /**
 231      * Creates this toolkit's implementation of <code>TextArea</code> using
 232      * the specified peer interface.
 233      * @param     target the text area to be implemented.
 234      * @return    this toolkit's implementation of <code>TextArea</code>.
 235      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 236      * returns true
 237      * @see       java.awt.GraphicsEnvironment#isHeadless
 238      * @see       java.awt.TextArea
 239      * @see       java.awt.peer.TextAreaPeer
 240      */
 241     protected abstract TextAreaPeer createTextArea(TextArea target)
 242         throws HeadlessException;
 243 
 244     /**
 245      * Creates this toolkit's implementation of <code>Choice</code> using
 246      * the specified peer interface.
 247      * @param     target the choice to be implemented.
 248      * @return    this toolkit's implementation of <code>Choice</code>.
 249      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 250      * returns true
 251      * @see       java.awt.GraphicsEnvironment#isHeadless
 252      * @see       java.awt.Choice
 253      * @see       java.awt.peer.ChoicePeer
 254      */
 255     protected abstract ChoicePeer createChoice(Choice target)
 256         throws HeadlessException;
 257 
 258     /**
 259      * Creates this toolkit's implementation of <code>Frame</code> using
 260      * the specified peer interface.
 261      * @param     target the frame to be implemented.
 262      * @return    this toolkit's implementation of <code>Frame</code>.
 263      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 264      * returns true
 265      * @see       java.awt.GraphicsEnvironment#isHeadless
 266      * @see       java.awt.Frame
 267      * @see       java.awt.peer.FramePeer
 268      */
 269     protected abstract FramePeer createFrame(Frame target)
 270         throws HeadlessException;
 271 
 272     /**
 273      * Creates this toolkit's implementation of <code>Canvas</code> using
 274      * the specified peer interface.
 275      * @param     target the canvas to be implemented.
 276      * @return    this toolkit's implementation of <code>Canvas</code>.
 277      * @see       java.awt.Canvas
 278      * @see       java.awt.peer.CanvasPeer
 279      */
 280     protected abstract CanvasPeer       createCanvas(Canvas target);
 281 
 282     /**
 283      * Creates this toolkit's implementation of <code>Panel</code> using
 284      * the specified peer interface.
 285      * @param     target the panel to be implemented.
 286      * @return    this toolkit's implementation of <code>Panel</code>.
 287      * @see       java.awt.Panel
 288      * @see       java.awt.peer.PanelPeer
 289      */
 290     protected abstract PanelPeer        createPanel(Panel target);
 291 
 292     /**
 293      * Creates this toolkit's implementation of <code>Window</code> using
 294      * the specified peer interface.
 295      * @param     target the window to be implemented.
 296      * @return    this toolkit's implementation of <code>Window</code>.
 297      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 298      * returns true
 299      * @see       java.awt.GraphicsEnvironment#isHeadless
 300      * @see       java.awt.Window
 301      * @see       java.awt.peer.WindowPeer
 302      */
 303     protected abstract WindowPeer createWindow(Window target)
 304         throws HeadlessException;
 305 
 306     /**
 307      * Creates this toolkit's implementation of <code>Dialog</code> using
 308      * the specified peer interface.
 309      * @param     target the dialog to be implemented.
 310      * @return    this toolkit's implementation of <code>Dialog</code>.
 311      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 312      * returns true
 313      * @see       java.awt.GraphicsEnvironment#isHeadless
 314      * @see       java.awt.Dialog
 315      * @see       java.awt.peer.DialogPeer
 316      */
 317     protected abstract DialogPeer createDialog(Dialog target)
 318         throws HeadlessException;
 319 
 320     /**
 321      * Creates this toolkit's implementation of <code>MenuBar</code> using
 322      * the specified peer interface.
 323      * @param     target the menu bar to be implemented.
 324      * @return    this toolkit's implementation of <code>MenuBar</code>.
 325      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 326      * returns true
 327      * @see       java.awt.GraphicsEnvironment#isHeadless
 328      * @see       java.awt.MenuBar
 329      * @see       java.awt.peer.MenuBarPeer
 330      */
 331     protected abstract MenuBarPeer createMenuBar(MenuBar target)
 332         throws HeadlessException;
 333 
 334     /**
 335      * Creates this toolkit's implementation of <code>Menu</code> using
 336      * the specified peer interface.
 337      * @param     target the menu to be implemented.
 338      * @return    this toolkit's implementation of <code>Menu</code>.
 339      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 340      * returns true
 341      * @see       java.awt.GraphicsEnvironment#isHeadless
 342      * @see       java.awt.Menu
 343      * @see       java.awt.peer.MenuPeer
 344      */
 345     protected abstract MenuPeer createMenu(Menu target)
 346         throws HeadlessException;
 347 
 348     /**
 349      * Creates this toolkit's implementation of <code>PopupMenu</code> using
 350      * the specified peer interface.
 351      * @param     target the popup menu to be implemented.
 352      * @return    this toolkit's implementation of <code>PopupMenu</code>.
 353      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 354      * returns true
 355      * @see       java.awt.GraphicsEnvironment#isHeadless
 356      * @see       java.awt.PopupMenu
 357      * @see       java.awt.peer.PopupMenuPeer
 358      * @since     1.1
 359      */
 360     protected abstract PopupMenuPeer createPopupMenu(PopupMenu target)
 361         throws HeadlessException;
 362 
 363     /**
 364      * Creates this toolkit's implementation of <code>MenuItem</code> using
 365      * the specified peer interface.
 366      * @param     target the menu item to be implemented.
 367      * @return    this toolkit's implementation of <code>MenuItem</code>.
 368      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 369      * returns true
 370      * @see       java.awt.GraphicsEnvironment#isHeadless
 371      * @see       java.awt.MenuItem
 372      * @see       java.awt.peer.MenuItemPeer
 373      */
 374     protected abstract MenuItemPeer createMenuItem(MenuItem target)
 375         throws HeadlessException;
 376 
 377     /**
 378      * Creates this toolkit's implementation of <code>FileDialog</code> using
 379      * the specified peer interface.
 380      * @param     target the file dialog to be implemented.
 381      * @return    this toolkit's implementation of <code>FileDialog</code>.
 382      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 383      * returns true
 384      * @see       java.awt.GraphicsEnvironment#isHeadless
 385      * @see       java.awt.FileDialog
 386      * @see       java.awt.peer.FileDialogPeer
 387      */
 388     protected abstract FileDialogPeer createFileDialog(FileDialog target)
 389         throws HeadlessException;
 390 
 391     /**
 392      * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using
 393      * the specified peer interface.
 394      * @param     target the checkbox menu item to be implemented.
 395      * @return    this toolkit's implementation of <code>CheckboxMenuItem</code>.
 396      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 397      * returns true
 398      * @see       java.awt.GraphicsEnvironment#isHeadless
 399      * @see       java.awt.CheckboxMenuItem
 400      * @see       java.awt.peer.CheckboxMenuItemPeer
 401      */
 402     protected abstract CheckboxMenuItemPeer createCheckboxMenuItem(
 403         CheckboxMenuItem target) throws HeadlessException;
 404 
 405     /**
 406      * Obtains this toolkit's implementation of helper class for
 407      * <code>MouseInfo</code> operations.
 408      * @return    this toolkit's implementation of  helper for <code>MouseInfo</code>
 409      * @throws    UnsupportedOperationException if this operation is not implemented
 410      * @see       java.awt.peer.MouseInfoPeer
 411      * @see       java.awt.MouseInfo
 412      * @since 1.5
 413      */
 414     protected MouseInfoPeer getMouseInfoPeer() {
 415         throw new UnsupportedOperationException("Not implemented");
 416     }
 417 
 418     private static LightweightPeer lightweightMarker;
 419 
 420     /**
 421      * Creates a peer for a component or container.  This peer is windowless
 422      * and allows the Component and Container classes to be extended directly
 423      * to create windowless components that are defined entirely in java.
 424      *
 425      * @param  target The Component to be created.
 426      * @return the peer for the specified component
 427      */
 428     protected LightweightPeer createComponent(Component target) {
 429         if (lightweightMarker == null) {
 430             lightweightMarker = new NullComponentPeer();
 431         }
 432         return lightweightMarker;
 433     }
 434 
 435     /**
 436      * Creates this toolkit's implementation of <code>Font</code> using
 437      * the specified peer interface.
 438      * @param     name the font to be implemented
 439      * @param     style the style of the font, such as <code>PLAIN</code>,
 440      *            <code>BOLD</code>, <code>ITALIC</code>, or a combination
 441      * @return    this toolkit's implementation of <code>Font</code>
 442      * @see       java.awt.Font
 443      * @see       java.awt.peer.FontPeer
 444      * @see       java.awt.GraphicsEnvironment#getAllFonts
 445      * @deprecated  see java.awt.GraphicsEnvironment#getAllFonts
 446      */
 447     @Deprecated
 448     protected abstract FontPeer getFontPeer(String name, int style);
 449 
 450     // The following method is called by the private method
 451     // <code>updateSystemColors</code> in <code>SystemColor</code>.
 452 
 453     /**
 454      * Fills in the integer array that is supplied as an argument
 455      * with the current system color values.
 456      *
 457      * @param     systemColors an integer array.
 458      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 459      * returns true
 460      * @see       java.awt.GraphicsEnvironment#isHeadless
 461      * @since     1.1
 462      */
 463     protected void loadSystemColors(int[] systemColors)
 464         throws HeadlessException {
 465         GraphicsEnvironment.checkHeadless();
 466     }
 467 
 468     /**
 469      * Controls whether the layout of Containers is validated dynamically


1732         if (security != null) {
1733             security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION);
1734         }
1735         return getSystemEventQueueImpl();
1736     }
1737 
1738     /**
1739      * Gets the application's or applet's <code>EventQueue</code>
1740      * instance, without checking access.  For security reasons,
1741      * this can only be called from a <code>Toolkit</code> subclass.
1742      * @return the <code>EventQueue</code> object
1743      */
1744     protected abstract EventQueue getSystemEventQueueImpl();
1745 
1746     /* Accessor method for use by AWT package routines. */
1747     static EventQueue getEventQueue() {
1748         return getDefaultToolkit().getSystemEventQueueImpl();
1749     }
1750 
1751     /**
1752      * Creates the peer for a DragSourceContext.
1753      * Always throws InvalidDndOperationException if
1754      * GraphicsEnvironment.isHeadless() returns true.
1755      *
1756      * @param  dge the {@code DragGestureEvent}
1757      * @return the peer created
1758      * @see java.awt.GraphicsEnvironment#isHeadless
1759      */
1760     public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
1761 
1762     /**
1763      * Creates a concrete, platform dependent, subclass of the abstract
1764      * DragGestureRecognizer class requested, and associates it with the
1765      * DragSource, Component and DragGestureListener specified.
1766      *
1767      * subclasses should override this to provide their own implementation
1768      *
1769      * @param abstractRecognizerClass The abstract class of the required recognizer
1770      * @param ds                      The DragSource
1771      * @param c                       The Component target for the DragGestureRecognizer
1772      * @param srcActions              The actions permitted for the gesture
1773      * @param dgl                     The DragGestureListener
1774      *
1775      * @return the new object or null.  Always returns null if
1776      * GraphicsEnvironment.isHeadless() returns true.
1777      * @see java.awt.GraphicsEnvironment#isHeadless
1778      */
1779     public <T extends DragGestureRecognizer> T
1780         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
1781                                     DragSource ds, Component c, int srcActions,
1782                                     DragGestureListener dgl)


   1 /*
   2  * Copyright (c) 1995, 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 java.awt;
  27 
  28 import java.awt.datatransfer.Clipboard;
  29 import java.awt.dnd.DragGestureListener;
  30 import java.awt.dnd.DragGestureRecognizer;
  31 import java.awt.dnd.DragSource;
  32 import java.awt.event.*;

  33 import java.awt.im.InputMethodHighlight;
  34 import java.awt.image.ColorModel;
  35 import java.awt.image.ImageObserver;
  36 import java.awt.image.ImageProducer;
  37 import java.beans.PropertyChangeEvent;
  38 import java.beans.PropertyChangeListener;
  39 import java.beans.PropertyChangeSupport;






  40 import java.io.File;
  41 import java.io.FileInputStream;
  42 import java.net.URL;
  43 import java.util.ArrayList;
  44 import java.util.EventListener;
  45 import java.util.HashMap;
  46 import java.util.Map;
  47 import java.util.MissingResourceException;
  48 import java.util.Properties;
  49 import java.util.ResourceBundle;
  50 import java.util.StringTokenizer;
  51 import java.util.WeakHashMap;
  52 
  53 import sun.awt.AWTAccessor;
  54 import sun.awt.AWTPermissions;

  55 import sun.awt.AppContext;

  56 import sun.awt.HeadlessToolkit;

  57 import sun.awt.PeerEvent;
  58 import sun.awt.SunToolkit;



  59 import sun.util.CoreResourceBundleControl;
  60 
  61 /**
  62  * This class is the abstract superclass of all actual
  63  * implementations of the Abstract Window Toolkit. Subclasses of
  64  * the <code>Toolkit</code> class are used to bind the various components
  65  * to particular native toolkit implementations.
  66  * <p>
  67  * Many GUI events may be delivered to user
  68  * asynchronously, if the opposite is not specified explicitly.
  69  * As well as
  70  * many GUI operations may be performed asynchronously.
  71  * This fact means that if the state of a component is set, and then
  72  * the state immediately queried, the returned value may not yet
  73  * reflect the requested change.  This behavior includes, but is not
  74  * limited to:
  75  * <ul>
  76  * <li>Scrolling to a specified position.
  77  * <br>For example, calling <code>ScrollPane.setScrollPosition</code>
  78  *     and then <code>getScrollPosition</code> may return an incorrect


  96  *     <code>Frame</code> or <code>Dialog</code> are forwarded
  97  *     to the underlying window management system and may be
  98  *     ignored or modified.  See {@link java.awt.Window} for
  99  *     more information.
 100  * </ul>
 101  * <p>
 102  * Most applications should not call any of the methods in this
 103  * class directly. The methods defined by <code>Toolkit</code> are
 104  * the "glue" that joins the platform-independent classes in the
 105  * <code>java.awt</code> package with their counterparts in
 106  * <code>java.awt.peer</code>. Some methods defined by
 107  * <code>Toolkit</code> query the native operating system directly.
 108  *
 109  * @author      Sami Shaio
 110  * @author      Arthur van Hoff
 111  * @author      Fred Ecks
 112  * @since       1.0
 113  */
 114 public abstract class Toolkit {
 115 















































































































































































































































































































































 116     // The following method is called by the private method
 117     // <code>updateSystemColors</code> in <code>SystemColor</code>.
 118 
 119     /**
 120      * Fills in the integer array that is supplied as an argument
 121      * with the current system color values.
 122      *
 123      * @param     systemColors an integer array.
 124      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 125      * returns true
 126      * @see       java.awt.GraphicsEnvironment#isHeadless
 127      * @since     1.1
 128      */
 129     protected void loadSystemColors(int[] systemColors)
 130         throws HeadlessException {
 131         GraphicsEnvironment.checkHeadless();
 132     }
 133 
 134     /**
 135      * Controls whether the layout of Containers is validated dynamically


1398         if (security != null) {
1399             security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION);
1400         }
1401         return getSystemEventQueueImpl();
1402     }
1403 
1404     /**
1405      * Gets the application's or applet's <code>EventQueue</code>
1406      * instance, without checking access.  For security reasons,
1407      * this can only be called from a <code>Toolkit</code> subclass.
1408      * @return the <code>EventQueue</code> object
1409      */
1410     protected abstract EventQueue getSystemEventQueueImpl();
1411 
1412     /* Accessor method for use by AWT package routines. */
1413     static EventQueue getEventQueue() {
1414         return getDefaultToolkit().getSystemEventQueueImpl();
1415     }
1416 
1417     /**











1418      * Creates a concrete, platform dependent, subclass of the abstract
1419      * DragGestureRecognizer class requested, and associates it with the
1420      * DragSource, Component and DragGestureListener specified.
1421      *
1422      * subclasses should override this to provide their own implementation
1423      *
1424      * @param abstractRecognizerClass The abstract class of the required recognizer
1425      * @param ds                      The DragSource
1426      * @param c                       The Component target for the DragGestureRecognizer
1427      * @param srcActions              The actions permitted for the gesture
1428      * @param dgl                     The DragGestureListener
1429      *
1430      * @return the new object or null.  Always returns null if
1431      * GraphicsEnvironment.isHeadless() returns true.
1432      * @see java.awt.GraphicsEnvironment#isHeadless
1433      */
1434     public <T extends DragGestureRecognizer> T
1435         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
1436                                     DragSource ds, Component c, int srcActions,
1437                                     DragGestureListener dgl)