jdk/src/share/classes/java/awt/Toolkit.java
author dav
Mon, 28 Mar 2011 15:25:24 +0400
changeset 8947 35ff89272f4f
parent 7668 d4a77089c587
child 9030 3de293b4cf4f
child 9205 9da0b52ce965
permissions -rw-r--r--
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE Reviewed-by: dcherepanov, art
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7009
diff changeset
     2
 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.MissingResourceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.ResourceBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.im.InputMethodHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.ImageProducer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.datatransfer.Clipboard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.dnd.DragSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.dnd.DragGestureRecognizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.dnd.DragGestureEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.dnd.DragGestureListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.dnd.InvalidDnDOperationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.dnd.peer.DragSourceContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.io.FileInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.util.*;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 1962
diff changeset
    51
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.beans.PropertyChangeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import sun.awt.HeadlessToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.awt.NullComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.awt.PeerEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.security.util.SecurityConstants;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import sun.util.CoreResourceBundleControl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * This class is the abstract superclass of all actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * implementations of the Abstract Window Toolkit. Subclasses of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * the <code>Toolkit</code> class are used to bind the various components
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * to particular native toolkit implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * Many GUI events may be delivered to user
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * asynchronously, if the opposite is not specified explicitly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * As well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * many GUI operations may be performed asynchronously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * This fact means that if the state of a component is set, and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * the state immediately queried, the returned value may not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * reflect the requested change.  This behavior includes, but is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * limited to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <li>Scrolling to a specified position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <br>For example, calling <code>ScrollPane.setScrollPosition</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *     and then <code>getScrollPosition</code> may return an incorrect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *     value if the original request has not yet been processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <li>Moving the focus from one component to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <br>For more information, see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#transferTiming">Timing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Focus Transfers</a>, a section in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * Tutorial</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <li>Making a top-level container visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <br>Calling <code>setVisible(true)</code> on a <code>Window</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *     <code>Frame</code> or <code>Dialog</code> may occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *     asynchronously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * <li>Setting the size or location of a top-level container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <br>Calls to <code>setSize</code>, <code>setBounds</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *     <code>setLocation</code> on a <code>Window</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *     <code>Frame</code> or <code>Dialog</code> are forwarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *     to the underlying window management system and may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *     ignored or modified.  See {@link java.awt.Window} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *     more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * Most applications should not call any of the methods in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * class directly. The methods defined by <code>Toolkit</code> are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * the "glue" that joins the platform-independent classes in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * <code>java.awt</code> package with their counterparts in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * <code>java.awt.peer</code>. Some methods defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * <code>Toolkit</code> query the native operating system directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * @author      Fred Ecks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
public abstract class Toolkit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Creates this toolkit's implementation of the <code>Desktop</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * using the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param     target the desktop to be implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @return    this toolkit's implementation of the <code>Desktop</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @see       java.awt.Desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @see       java.awt.peer.DesktopPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    protected abstract DesktopPeer createDesktopPeer(Desktop target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Creates this toolkit's implementation of <code>Button</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @param     target the button to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @return    this toolkit's implementation of <code>Button</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @see       java.awt.Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @see       java.awt.peer.ButtonPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    protected abstract ButtonPeer createButton(Button target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Creates this toolkit's implementation of <code>TextField</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param     target the text field to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @return    this toolkit's implementation of <code>TextField</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @see       java.awt.TextField
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see       java.awt.peer.TextFieldPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    protected abstract TextFieldPeer createTextField(TextField target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Creates this toolkit's implementation of <code>Label</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param     target the label to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @return    this toolkit's implementation of <code>Label</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @see       java.awt.Label
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @see       java.awt.peer.LabelPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected abstract LabelPeer createLabel(Label target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * Creates this toolkit's implementation of <code>List</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param     target the list to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @return    this toolkit's implementation of <code>List</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @see       java.awt.List
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @see       java.awt.peer.ListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    protected abstract ListPeer createList(java.awt.List target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Creates this toolkit's implementation of <code>Checkbox</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param     target the check box to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @return    this toolkit's implementation of <code>Checkbox</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @see       java.awt.Checkbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see       java.awt.peer.CheckboxPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    protected abstract CheckboxPeer createCheckbox(Checkbox target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Creates this toolkit's implementation of <code>Scrollbar</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param     target the scroll bar to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @return    this toolkit's implementation of <code>Scrollbar</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @see       java.awt.Scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @see       java.awt.peer.ScrollbarPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    protected abstract ScrollbarPeer createScrollbar(Scrollbar target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Creates this toolkit's implementation of <code>ScrollPane</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @param     target the scroll pane to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @return    this toolkit's implementation of <code>ScrollPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @see       java.awt.ScrollPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @see       java.awt.peer.ScrollPanePeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    protected abstract ScrollPanePeer createScrollPane(ScrollPane target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Creates this toolkit's implementation of <code>TextArea</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @param     target the text area to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @return    this toolkit's implementation of <code>TextArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @see       java.awt.TextArea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @see       java.awt.peer.TextAreaPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    protected abstract TextAreaPeer createTextArea(TextArea target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Creates this toolkit's implementation of <code>Choice</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @param     target the choice to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @return    this toolkit's implementation of <code>Choice</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @see       java.awt.Choice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see       java.awt.peer.ChoicePeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    protected abstract ChoicePeer createChoice(Choice target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Creates this toolkit's implementation of <code>Frame</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param     target the frame to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @return    this toolkit's implementation of <code>Frame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @see       java.awt.Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @see       java.awt.peer.FramePeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    protected abstract FramePeer createFrame(Frame target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Creates this toolkit's implementation of <code>Canvas</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param     target the canvas to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @return    this toolkit's implementation of <code>Canvas</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @see       java.awt.Canvas
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @see       java.awt.peer.CanvasPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    protected abstract CanvasPeer       createCanvas(Canvas target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Creates this toolkit's implementation of <code>Panel</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @param     target the panel to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @return    this toolkit's implementation of <code>Panel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see       java.awt.Panel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @see       java.awt.peer.PanelPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    protected abstract PanelPeer        createPanel(Panel target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Creates this toolkit's implementation of <code>Window</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param     target the window to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @return    this toolkit's implementation of <code>Window</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @see       java.awt.Window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @see       java.awt.peer.WindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    protected abstract WindowPeer createWindow(Window target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Creates this toolkit's implementation of <code>Dialog</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @param     target the dialog to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @return    this toolkit's implementation of <code>Dialog</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @see       java.awt.Dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @see       java.awt.peer.DialogPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    protected abstract DialogPeer createDialog(Dialog target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * Creates this toolkit's implementation of <code>MenuBar</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param     target the menu bar to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @return    this toolkit's implementation of <code>MenuBar</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @see       java.awt.MenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @see       java.awt.peer.MenuBarPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    protected abstract MenuBarPeer createMenuBar(MenuBar target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * Creates this toolkit's implementation of <code>Menu</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @param     target the menu to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @return    this toolkit's implementation of <code>Menu</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @see       java.awt.Menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @see       java.awt.peer.MenuPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    protected abstract MenuPeer createMenu(Menu target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Creates this toolkit's implementation of <code>PopupMenu</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param     target the popup menu to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @return    this toolkit's implementation of <code>PopupMenu</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @see       java.awt.PopupMenu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @see       java.awt.peer.PopupMenuPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    protected abstract PopupMenuPeer createPopupMenu(PopupMenu target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Creates this toolkit's implementation of <code>MenuItem</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @param     target the menu item to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @return    this toolkit's implementation of <code>MenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @see       java.awt.MenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @see       java.awt.peer.MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    protected abstract MenuItemPeer createMenuItem(MenuItem target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * Creates this toolkit's implementation of <code>FileDialog</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @param     target the file dialog to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @return    this toolkit's implementation of <code>FileDialog</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @see       java.awt.FileDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @see       java.awt.peer.FileDialogPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    protected abstract FileDialogPeer createFileDialog(FileDialog target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @param     target the checkbox menu item to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @return    this toolkit's implementation of <code>CheckboxMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see       java.awt.CheckboxMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @see       java.awt.peer.CheckboxMenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    protected abstract CheckboxMenuItemPeer createCheckboxMenuItem(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        CheckboxMenuItem target) throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Obtains this toolkit's implementation of helper class for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * <code>MouseInfo</code> operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return    this toolkit's implementation of  helper for <code>MouseInfo</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @throws    UnsupportedOperationException if this operation is not implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see       java.awt.peer.MouseInfoPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @see       java.awt.MouseInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    protected MouseInfoPeer getMouseInfoPeer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        throw new UnsupportedOperationException("Not implemented");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    private static LightweightPeer lightweightMarker;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Creates a peer for a component or container.  This peer is windowless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * and allows the Component and Container classes to be extended directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * to create windowless components that are defined entirely in java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @param target The Component to be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    protected LightweightPeer createComponent(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        if (lightweightMarker == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            lightweightMarker = new NullComponentPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return lightweightMarker;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * Creates this toolkit's implementation of <code>Font</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * the specified peer interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @param     name the font to be implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param     style the style of the font, such as <code>PLAIN</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *            <code>BOLD</code>, <code>ITALIC</code>, or a combination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @return    this toolkit's implementation of <code>Font</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @see       java.awt.Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @see       java.awt.peer.FontPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @see       java.awt.GraphicsEnvironment#getAllFonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @deprecated  see java.awt.GraphicsEnvironment#getAllFonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    protected abstract FontPeer getFontPeer(String name, int style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    // The following method is called by the private method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    // <code>updateSystemColors</code> in <code>SystemColor</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Fills in the integer array that is supplied as an argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * with the current system color values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @param     systemColors an integer array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    protected void loadSystemColors(int[] systemColors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Controls whether the layout of Containers is validated dynamically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * during resizing, or statically, after resizing is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * Use {@code isDynamicLayoutActive()} to detect if this feature enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * in this program and is supported by this operating system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * and/or window manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * Note that this feature is supported not on all platforms, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * conversely, that this feature cannot be turned off on some platforms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * On these platforms where dynamic layout during resizing is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * (or is always supported), setting this property has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * Note that this feature can be set or unset as a property of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * operating system or window manager on some platforms.  On such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * platforms, the dynamic resize property must be set at the operating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * system or window manager level before this method can take effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * This method does not change support or settings of the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * operating system or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * window manager.  The OS/WM support can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * queried using getDesktopProperty("awt.dynamicLayoutSupported") method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @param     dynamic  If true, Containers should re-layout their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *            components as the Container is being resized.  If false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *            the layout will be validated after resizing is completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see       #isDynamicLayoutSet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @see       #isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @see       #getDesktopProperty(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public void setDynamicLayout(boolean dynamic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Returns whether the layout of Containers is validated dynamically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * during resizing, or statically, after resizing is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * Note: this method returns the value that was set programmatically;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * it does not reflect support at the level of the operating system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * or window manager for dynamic layout on resizing, or the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * operating system or window manager settings.  The OS/WM support can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * be queried using getDesktopProperty("awt.dynamicLayoutSupported").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @return    true if validation of Containers is done dynamically,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *            false if validation is done after resizing is finished.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see       #setDynamicLayout(boolean dynamic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @see       #isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @see       #getDesktopProperty(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    protected boolean isDynamicLayoutSet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            return Toolkit.getDefaultToolkit().isDynamicLayoutSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * Returns whether dynamic layout of Containers on resize is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * currently active (both set in program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *( {@code isDynamicLayoutSet()} )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *, and supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * by the underlying operating system and/or window manager).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * If dynamic layout is currently inactive then Containers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * re-layout their components when resizing is completed. As a result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * the {@code Component.validate()} method will be invoked only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * once per resize.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * If dynamic layout is currently active then Containers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * re-layout their components on every native resize event and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * the {@code validate()} method will be invoked each time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * The OS/WM support can be queried using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * the getDesktopProperty("awt.dynamicLayoutSupported") method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * @return    true if dynamic layout of Containers on resize is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *            currently active, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @exception HeadlessException if the GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *            method returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @see       #setDynamicLayout(boolean dynamic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @see       #isDynamicLayoutSet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @see       #getDesktopProperty(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    public boolean isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            return Toolkit.getDefaultToolkit().isDynamicLayoutActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * Gets the size of the screen.  On systems with multiple displays, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * primary display is used.  Multi-screen aware display dimensions are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * available from <code>GraphicsConfiguration</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * <code>GraphicsDevice</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @return    the size of this toolkit's screen, in pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @see       java.awt.GraphicsConfiguration#getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @see       java.awt.GraphicsDevice#getDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    public abstract Dimension getScreenSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * Returns the screen resolution in dots-per-inch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @return    this toolkit's screen resolution, in dots-per-inch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    public abstract int getScreenResolution()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * Gets the insets of the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @param     gc a <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * @return    the insets of this toolkit's screen, in pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public Insets getScreenInsets(GraphicsConfiguration gc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            return Toolkit.getDefaultToolkit().getScreenInsets(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            return new Insets(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Determines the color model of this toolkit's screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * <code>ColorModel</code> is an abstract class that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * encapsulates the ability to translate between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * pixel values of an image and its red, green, blue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * and alpha components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * This toolkit method is called by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * <code>getColorModel</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * of the <code>Component</code> class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @return    the color model of this toolkit's screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @see       java.awt.image.ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @see       java.awt.Component#getColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public abstract ColorModel getColorModel()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * Returns the names of the available fonts in this toolkit.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * For 1.1, the following font names are deprecated (the replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * name follows):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * <li>TimesRoman (use Serif)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * <li>Helvetica (use SansSerif)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * <li>Courier (use Monospaced)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * </ul><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * The ZapfDingbats fontname is also deprecated in 1.1 but the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * are defined in Unicode starting at 0x2700, and as of 1.1 Java supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * those characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @return    the names of the available fonts in this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @deprecated see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @see java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    public abstract String[] getFontList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * Gets the screen device metrics for rendering of the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * @param     font   a font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @return    the screen metrics of the specified font in this toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @deprecated  As of JDK version 1.2, replaced by the <code>Font</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     *          method <code>getLineMetrics</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @see java.awt.font.LineMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see java.awt.Font#getLineMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @see java.awt.GraphicsEnvironment#getScreenDevices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    public abstract FontMetrics getFontMetrics(Font font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * Synchronizes this toolkit's graphics state. Some window systems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * may do buffering of graphics events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * This method ensures that the display is up-to-date. It is useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * for animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public abstract void sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * The default toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    private static Toolkit toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * Used internally by the assistive technologies functions; set at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * init time and used at load time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    private static String atNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * Initializes properties related to assistive technologies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * These properties are used both in the loadAssistiveProperties()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * function below, as well as other classes in the jdk that depend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * on the properties (such as the use of the screen_magnifier_present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * property in Java2D hardware acceleration initialization).  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * initialization of the properties must be done before the platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * specific Toolkit class is instantiated so that all necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * properties are set up properly before any classes dependent upon them
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * are initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    private static void initAssistiveTechnologies() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        // Get accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        final String sep = File.separator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        final Properties properties = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        atNames = (String)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                // Try loading the per-user accessibility properties file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                    File propsFile = new File(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                      System.getProperty("user.home") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                      sep + ".accessibility.properties");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                    FileInputStream in =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                        new FileInputStream(propsFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                    // Inputstream has been buffered in Properties class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                    properties.load(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                    in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    // Per-user accessibility properties file does not exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                // Try loading the system-wide accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                // file only if a per-user accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                // file does not exist or is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                if (properties.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                        File propsFile = new File(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                            System.getProperty("java.home") + sep + "lib" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                            sep + "accessibility.properties");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                        FileInputStream in =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                            new FileInputStream(propsFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                        // Inputstream has been buffered in Properties class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                        properties.load(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                    } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                        // System-wide accessibility properties file does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                        // not exist;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                // Get whether a screen magnifier is present.  First check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                // the system property and then check the properties file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                String magPresent = System.getProperty("javax.accessibility.screen_magnifier_present");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                if (magPresent == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                    magPresent = properties.getProperty("screen_magnifier_present", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                    if (magPresent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                        System.setProperty("javax.accessibility.screen_magnifier_present", magPresent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                // Get the names of any assistive technolgies to load.  First
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                // check the system property and then check the properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                // file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                String classNames = System.getProperty("javax.accessibility.assistive_technologies");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                if (classNames == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                    classNames = properties.getProperty("assistive_technologies", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                    if (classNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                        System.setProperty("javax.accessibility.assistive_technologies", classNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                return classNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * Loads additional classes into the VM, using the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * 'assistive_technologies' specified in the Sun reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * implementation by a line in the 'accessibility.properties'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * file.  The form is "assistive_technologies=..." where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * the "..." is a comma-separated list of assistive technology
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * classes to load.  Each class is loaded in the order given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * and a single instance of each is created using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * Class.forName(class).newInstance().  All errors are handled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * via an AWTError exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <p>The assumption is made that assistive technology classes are supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * as part of INSTALLED (as opposed to: BUNDLED) extensions or specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * on the class path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * (and therefore can be loaded using the class loader returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * a call to <code>ClassLoader.getSystemClassLoader</code>, whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * delegation parent is the extension class loader for installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * extensions).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    private static void loadAssistiveTechnologies() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        // Load any assistive technologies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        if (atNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            ClassLoader cl = ClassLoader.getSystemClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            StringTokenizer parser = new StringTokenizer(atNames," ,");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            String atName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            while (parser.hasMoreTokens()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                atName = parser.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                    Class clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                    if (cl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                        clazz = cl.loadClass(atName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                        clazz = Class.forName(atName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                    clazz.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                    throw new AWTError("Assistive Technology not found: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                            + atName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                } catch (InstantiationException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                    throw new AWTError("Could not instantiate Assistive"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                            + " Technology: " + atName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                    throw new AWTError("Could not access Assistive"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                            + " Technology: " + atName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                    throw new AWTError("Error trying to install Assistive"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                            + " Technology: " + atName + " " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * Gets the default toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * If a system property named <code>"java.awt.headless"</code> is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * to <code>true</code> then the headless implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * of <code>Toolkit</code> is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * If there is no <code>"java.awt.headless"</code> or it is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * <code>false</code> and there is a system property named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * <code>"awt.toolkit"</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * that property is treated as the name of a class that is a subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * of <code>Toolkit</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * otherwise the default platform-specific implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * <code>Toolkit</code> is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * Also loads additional classes into the VM, using the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * 'assistive_technologies' specified in the Sun reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * implementation by a line in the 'accessibility.properties'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * file.  The form is "assistive_technologies=..." where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * the "..." is a comma-separated list of assistive technology
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * classes to load.  Each class is loaded in the order given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * and a single instance of each is created using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * Class.forName(class).newInstance().  This is done just after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * the AWT toolkit is created.  All errors are handled via an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * AWTError exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * @return    the default toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @exception  AWTError  if a toolkit could not be found, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     *                 if one could not be accessed or instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    public static synchronized Toolkit getDefaultToolkit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        if (toolkit == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                // We disable the JIT during toolkit initialization.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                // tends to touch lots of classes that aren't needed again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                // later and therefore JITing is counter-productiive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                java.lang.Compiler.disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                        new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                    public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                        String nm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                        Class cls = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                            nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                                cls = Class.forName(nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                            } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                                ClassLoader cl = ClassLoader.getSystemClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                                if (cl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                                        cls = cl.loadClass(nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                                    } catch (ClassNotFoundException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                                        throw new AWTError("Toolkit not found: " + nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                            if (cls != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                                toolkit = (Toolkit)cls.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                                if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                                    toolkit = new HeadlessToolkit(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                        } catch (InstantiationException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                            throw new AWTError("Could not instantiate Toolkit: " + nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                            throw new AWTError("Could not access Toolkit: " + nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                loadAssistiveTechnologies();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                // Make sure to always re-enable the JIT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                java.lang.Compiler.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        return toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * Returns an image which gets pixel data from the specified file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * whose format can be either GIF, JPEG or PNG.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * The underlying toolkit attempts to resolve multiple requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * with the same filename to the same returned Image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * Since the mechanism required to facilitate this sharing of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * <code>Image</code> objects may continue to hold onto images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * that are no longer in use for an indefinite period of time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     * developers are encouraged to implement their own caching of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * images by using the {@link #createImage(java.lang.String) createImage}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     * variant wherever available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     * If the image data contained in the specified file changes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * the <code>Image</code> object returned from this method may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * still contain stale information which was loaded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * file after a prior call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * Previously loaded image data can be manually discarded by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * calling the {@link Image#flush flush} method on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * returned <code>Image</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * If so, the method calls the security manager's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * <code>checkRead</code> method with the file specified to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * that the access to the image is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @param     filename   the name of a file containing pixel data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     *                         in a recognized file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     *                         the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     *                            checkRead method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * @see #createImage(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    public abstract Image getImage(String filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     * Returns an image which gets pixel data from the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * The pixel data referenced by the specified URL must be in one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * of the following formats: GIF, JPEG or PNG.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * The underlying toolkit attempts to resolve multiple requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * with the same URL to the same returned Image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * Since the mechanism required to facilitate this sharing of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * <code>Image</code> objects may continue to hold onto images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * that are no longer in use for an indefinite period of time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * developers are encouraged to implement their own caching of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * images by using the {@link #createImage(java.net.URL) createImage}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * variant wherever available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * If the image data stored at the specified URL changes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * the <code>Image</code> object returned from this method may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * still contain stale information which was fetched from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * URL after a prior call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * Previously loaded image data can be manually discarded by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * calling the {@link Image#flush flush} method on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * returned <code>Image</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * If so, the method calls the security manager's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * <code>checkPermission</code> method with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * url.openConnection().getPermission() permission to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * that the access to the image is allowed. For compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * with pre-1.2 security managers, if the access is denied with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * <code>FilePermission</code> or <code>SocketPermission</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * the method throws the <code>SecurityException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * if the corresponding 1.1-style SecurityManager.checkXXX method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * also denies permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * @param     url   the URL to use in fetching the pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     *                         the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     *                            checkPermission method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     *                            the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     * @see #createImage(java.net.URL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    public abstract Image getImage(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * Returns an image which gets pixel data from the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * The returned Image is a new object which will not be shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * with any other caller of this method or its getImage variant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * If so, the method calls the security manager's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * <code>checkRead</code> method with the specified file to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * that the image creation is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @param     filename   the name of a file containing pixel data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     *                         in a recognized file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     *                         the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     *                            checkRead method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @see #getImage(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    public abstract Image createImage(String filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * Returns an image which gets pixel data from the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * The returned Image is a new object which will not be shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * with any other caller of this method or its getImage variant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * If so, the method calls the security manager's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * <code>checkPermission</code> method with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * url.openConnection().getPermission() permission to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * that the image creation is allowed. For compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * with pre-1.2 security managers, if the access is denied with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * <code>FilePermission</code> or <code>SocketPermission</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * the method throws <code>SecurityException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * if the corresponding 1.1-style SecurityManager.checkXXX method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * also denies permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * @param     url   the URL to use in fetching the pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *                         the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *                            checkPermission method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     *                            the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * @see #getImage(java.net.URL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    public abstract Image createImage(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * Prepares an image for rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * If the values of the width and height arguments are both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * <code>-1</code>, this method prepares the image for rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * on the default screen; otherwise, this method prepares an image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * for rendering on the default screen at the specified width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * The image data is downloaded asynchronously in another thread,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * and an appropriately scaled screen representation of the image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * This method is called by components <code>prepareImage</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * Information on the flags returned by this method can be found
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * with the definition of the <code>ImageObserver</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * @param     image      the image for which to prepare a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     *                           screen representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @param     width      the width of the desired screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     *                           representation, or <code>-1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * @param     height     the height of the desired screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     *                           representation, or <code>-1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @param     observer   the <code>ImageObserver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     *                           object to be notified as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     *                           image is being prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * @return    <code>true</code> if the image has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     *                 fully prepared; <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * @see       java.awt.Component#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *                 java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * @see       java.awt.Component#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     * @see       java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    public abstract boolean prepareImage(Image image, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                                         ImageObserver observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * Indicates the construction status of a specified image that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * being prepared for display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * If the values of the width and height arguments are both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * <code>-1</code>, this method returns the construction status of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * a screen representation of the specified image in this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * Otherwise, this method returns the construction status of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * scaled representation of the image at the specified width
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * This method does not cause the image to begin loading.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * An application must call <code>prepareImage</code> to force
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * the loading of an image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * This method is called by the component's <code>checkImage</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     * Information on the flags returned by this method can be found
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * with the definition of the <code>ImageObserver</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     * @param     image   the image whose status is being checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @param     width   the width of the scaled version whose status is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     *                 being checked, or <code>-1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     * @param     height  the height of the scaled version whose status
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     *                 is being checked, or <code>-1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     * @param     observer   the <code>ImageObserver</code> object to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     *                 notified as the image is being prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     * @return    the bitwise inclusive <strong>OR</strong> of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     *                 <code>ImageObserver</code> flags for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     *                 image data that is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * @see       java.awt.Toolkit#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * @see       java.awt.Component#checkImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     *                 java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * @see       java.awt.Component#checkImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
     * @see       java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    public abstract int checkImage(Image image, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                                   ImageObserver observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * Creates an image with the specified image producer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * @param     producer the image producer to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * @return    an image with the specified image producer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * @see       java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     * @see       java.awt.image.ImageProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     * @see       java.awt.Component#createImage(java.awt.image.ImageProducer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    public abstract Image createImage(ImageProducer producer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * Creates an image which decodes the image stored in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
     * byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * The data must be in some image format, such as GIF or JPEG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * that is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     * @param     imagedata   an array of bytes, representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     *                         image data in a supported image format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     * @return    an image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    public Image createImage(byte[] imagedata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        return createImage(imagedata, 0, imagedata.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * Creates an image which decodes the image stored in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * byte array, and at the specified offset and length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * The data must be in some image format, such as GIF or JPEG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * that is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * @param     imagedata   an array of bytes, representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *                         image data in a supported image format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @param     imageoffset  the offset of the beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     *                         of the data in the array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * @param     imagelength  the length of the data in the array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * @return    an image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    public abstract Image createImage(byte[] imagedata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                                      int imageoffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                                      int imagelength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     * Gets a <code>PrintJob</code> object which is the result of initiating
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * a print operation on the toolkit's platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * is a security manager installed. If there is, the method should call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
     * the security manager's <code>checkPrintJobAccess</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     * ensure initiation of a print operation is allowed. If the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     * implementation of <code>checkPrintJobAccess</code> is used (that is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     * that method is not overriden), then this results in a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * security manager's <code>checkPermission</code> method with a <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * RuntimePermission("queuePrintJob")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * @param   frame the parent of the print dialog. May not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * @param   jobtitle the title of the PrintJob. A null title is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
     *          to "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * @param   props a Properties object containing zero or more properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     *          Properties are not standardized and are not consistent across
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     *          implementations. Because of this, PrintJobs which require job
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     *          and page control should use the version of this function which
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     *          takes JobAttributes and PageAttributes objects. This object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     *          may be updated to reflect the user's job choices on exit. May
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     *          be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     * @return  a <code>PrintJob</code> object, or <code>null</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     *          user cancelled the print job.
8947
35ff89272f4f 7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents: 7668
diff changeset
  1162
     * @throws  NullPointerException if frame is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     * @throws  SecurityException if this thread is not allowed to initiate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     *          print job request
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * @see     java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
     * @see     java.awt.PrintJob
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
     * @see     java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                                         Properties props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
     * Gets a <code>PrintJob</code> object which is the result of initiating
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * a print operation on the toolkit's platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * is a security manager installed. If there is, the method should call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * the security manager's <code>checkPrintJobAccess</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     * ensure initiation of a print operation is allowed. If the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * implementation of <code>checkPrintJobAccess</code> is used (that is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * that method is not overriden), then this results in a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * security manager's <code>checkPermission</code> method with a <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * RuntimePermission("queuePrintJob")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * @param   frame the parent of the print dialog. May be null if and only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     *          if jobAttributes is not null and jobAttributes.getDialog()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
     *          returns JobAttributes.DialogType.NONE or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
     *          JobAttributes.DialogType.COMMON.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
     * @param   jobtitle the title of the PrintJob. A null title is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     *          to "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * @param   jobAttributes a set of job attributes which will control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     *          PrintJob. The attributes will be updated to reflect the user's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     *          choices as outlined in the JobAttributes documentation. May be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     *          null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * @param   pageAttributes a set of page attributes which will control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     *          PrintJob. The attributes will be applied to every page in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     *          job. The attributes will be updated to reflect the user's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     *          choices as outlined in the PageAttributes documentation. May be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
     *          null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     * @return  a <code>PrintJob</code> object, or <code>null</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
     *          user cancelled the print job.
8947
35ff89272f4f 7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents: 7668
diff changeset
  1203
     * @throws  NullPointerException if frame is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     * @throws  IllegalArgumentException if pageAttributes specifies differing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
     *          cross feed and feed resolutions. Also if this thread has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     *          access to the file system and jobAttributes specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     *          print to file, and the specified destination file exists but
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     *          is a directory rather than a regular file, does not exist but
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     *          cannot be created, or cannot be opened for any other reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     *          However in the case of print to file, if a dialog is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     *          requested to be displayed then the user will be given an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     *          opportunity to select a file and proceed with printing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     *          The dialog will ensure that the selected output file
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
     *          is valid before returning from this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     * @throws  SecurityException if this thread is not allowed to initiate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
     *          print job request, or if jobAttributes specifies print to file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     *          and this thread is not allowed to access the file system
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     * @see     java.awt.PrintJob
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * @see     java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * @see     java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * @see     java.awt.JobAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     * @see     java.awt.PageAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * @since   1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
    public PrintJob getPrintJob(Frame frame, String jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                                JobAttributes jobAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                                PageAttributes pageAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        // Override to add printing support with new job/page control classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                                                           jobAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                                                           pageAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            return getPrintJob(frame, jobtitle, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * Emits an audio beep.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    public abstract void beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     * Gets the singleton instance of the system Clipboard which interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     * with clipboard facilities provided by the native platform. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
     * clipboard enables data transfer between Java programs and native
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     * applications which use native clipboard facilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * In addition to any and all formats specified in the flavormap.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
     * file, or other file specified by the <code>AWT.DnD.flavorMapFileURL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     * </code> Toolkit property, text returned by the system Clipboard's <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
     * getTransferData()</code> method is available in the following flavors:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * <li>DataFlavor.stringFlavor</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
     * <li>DataFlavor.plainTextFlavor (<b>deprecated</b>)</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     * As with <code>java.awt.datatransfer.StringSelection</code>, if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * requested flavor is <code>DataFlavor.plainTextFlavor</code>, or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * equivalent flavor, a Reader is returned. <b>Note:</b> The behavior of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     * the system Clipboard's <code>getTransferData()</code> method for <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
     * DataFlavor.plainTextFlavor</code>, and equivalent DataFlavors, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
     * inconsistent with the definition of <code>DataFlavor.plainTextFlavor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * </code>. Because of this, support for <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * DataFlavor.plainTextFlavor</code>, and equivalent flavors, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * <b>deprecated</b>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
     * is a security manager installed. If there is, the method should call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * the security manager's <code>checkSystemClipboardAccess</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     * to ensure it's ok to to access the system clipboard. If the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * implementation of <code>checkSystemClipboardAccess</code> is used (that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     * is, that method is not overriden), then this results in a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * security manager's <code>checkPermission</code> method with an <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     * AWTPermission("accessClipboard")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @return    the system Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * @see       java.awt.datatransfer.Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * @see       java.awt.datatransfer.StringSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * @see       java.awt.datatransfer.DataFlavor#stringFlavor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * @see       java.awt.datatransfer.DataFlavor#plainTextFlavor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     * @see       java.io.Reader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     * @see       java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
    public abstract Clipboard getSystemClipboard()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     * Gets the singleton instance of the system selection as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
     * <code>Clipboard</code> object. This allows an application to read and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
     * modify the current, system-wide selection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
     * An application is responsible for updating the system selection whenever
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
     * the user selects text, using either the mouse or the keyboard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
     * Typically, this is implemented by installing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
     * <code>FocusListener</code> on all <code>Component</code>s which support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
     * text selection, and, between <code>FOCUS_GAINED</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     * <code>FOCUS_LOST</code> events delivered to that <code>Component</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * updating the system selection <code>Clipboard</code> when the selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     * changes inside the <code>Component</code>. Properly updating the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * selection ensures that a Java application will interact correctly with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     * native applications and other Java applications running simultaneously
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
     * on the system. Note that <code>java.awt.TextComponent</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
     * <code>javax.swing.text.JTextComponent</code> already adhere to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     * policy. When using these classes, and their subclasses, developers need
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     * not write any additional code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
     * Some platforms do not support a system selection <code>Clipboard</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
     * On those platforms, this method will return <code>null</code>. In such a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
     * case, an application is absolved from its responsibility to update the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
     * system selection <code>Clipboard</code> as described above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     * is a <code>SecurityManager</code> installed. If there is, the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
     * should call the <code>SecurityManager</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     * <code>checkSystemClipboardAccess</code> method to ensure that client
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * code has access the system selection. If the default implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     * <code>checkSystemClipboardAccess</code> is used (that is, if the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
     * is not overridden), then this results in a call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
     * <code>SecurityManager</code>'s <code>checkPermission</code> method with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
     * an <code>AWTPermission("accessClipboard")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
     * @return the system selection as a <code>Clipboard</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
     *         <code>null</code> if the native platform does not support a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     *         system selection <code>Clipboard</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
     * @see java.awt.datatransfer.Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
     * @see java.awt.event.FocusListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
     * @see java.awt.event.FocusEvent#FOCUS_GAINED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
     * @see java.awt.event.FocusEvent#FOCUS_LOST
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
     * @see TextComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
     * @see javax.swing.text.JTextComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
     * @see AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
     * @see GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    public Clipboard getSystemSelection() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
            return Toolkit.getDefaultToolkit().getSystemSelection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
            GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * Determines which modifier key is the appropriate accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     * key for menu shortcuts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * Menu shortcuts, which are embodied in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     * <code>MenuShortcut</code> class, are handled by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     * <code>MenuBar</code> class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
     * By default, this method returns <code>Event.CTRL_MASK</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
     * Toolkit implementations should override this method if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
     * <b>Control</b> key isn't the correct key for accelerators.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
     * @return    the modifier mask on the <code>Event</code> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
     *                 that is used for menu shortcuts on this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * @see       java.awt.MenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * @see       java.awt.MenuShortcut
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
    public int getMenuShortcutKeyMask() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        return Event.CTRL_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     * Returns whether the given locking key on the keyboard is currently in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     * its "on" state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     * Valid key codes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
     * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
     * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     * @exception java.lang.IllegalArgumentException if <code>keyCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * is not one of the valid key codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * @exception java.lang.UnsupportedOperationException if the host system doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * allow getting the state of this key programmatically, or if the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * doesn't have this key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
    public boolean getLockingKeyState(int keyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
        throws UnsupportedOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        throw new UnsupportedOperationException("Toolkit.getLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     * Sets the state of the given locking key on the keyboard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     * Valid key codes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
     * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
     * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
     * Depending on the platform, setting the state of a locking key may
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * involve event processing and therefore may not be immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
     * observable through getLockingKeyState.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
     * @exception java.lang.IllegalArgumentException if <code>keyCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
     * is not one of the valid key codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
     * @exception java.lang.UnsupportedOperationException if the host system doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
     * allow setting the state of this key programmatically, or if the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
     * doesn't have this key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
    public void setLockingKeyState(int keyCode, boolean on)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
        throws UnsupportedOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
            throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        throw new UnsupportedOperationException("Toolkit.setLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
     * Give native peers the ability to query the native container
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
     * given a native component (eg the direct parent may be lightweight).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    protected static Container getNativeContainer(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        return c.getNativeContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
     * Creates a new custom cursor object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
     * If the image to display is invalid, the cursor will be hidden (made
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
     * completely transparent), and the hotspot will be set to (0, 0).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
     * <p>Note that multi-frame images are invalid and may cause this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
     * method to hang.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
     * @param cursor the image to display when the cursor is actived
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
     * @param hotSpot the X and Y of the large cursor's hot spot; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
     *   hotSpot values must be less than the Dimension returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
     *   <code>getBestCursorSize</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
     * @param     name a localized description of the cursor, for Java Accessibility use
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
     * @exception IndexOutOfBoundsException if the hotSpot values are outside
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
     *   the bounds of the cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
    public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
        throws IndexOutOfBoundsException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                createCustomCursor(cursor, hotSpot, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
            return new Cursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
     * Returns the supported cursor dimension which is closest to the desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
     * sizes.  Systems which only support a single cursor size will return that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
     * size regardless of the desired sizes.  Systems which don't support custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
     * cursors will return a dimension of 0, 0. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
     * Note:  if an image is used whose dimensions don't match a supported size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
     * (as returned by this method), the Toolkit implementation will attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
     * resize the image to a supported size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
     * Since converting low-resolution images is difficult,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
     * no guarantees are made as to the quality of a cursor image which isn't a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
     * supported size.  It is therefore recommended that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
     * be called and an appropriate image used so no image conversion is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
     * @param     preferredWidth the preferred cursor width the component would like
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
     * to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * @param     preferredHeight the preferred cursor height the component would like
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * @return    the closest matching supported cursor size, or a dimension of 0,0 if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * the Toolkit implementation doesn't support custom cursors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
    public Dimension getBestCursorSize(int preferredWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
        int preferredHeight) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
                getBestCursorSize(preferredWidth, preferredHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
            return new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
     * Returns the maximum number of colors the Toolkit supports in a custom cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
     * palette.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
     * Note: if an image is used which has more colors in its palette than
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
     * the supported maximum, the Toolkit implementation will attempt to flatten the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
     * palette to the maximum.  Since converting low-resolution images is difficult,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
     * no guarantees are made as to the quality of a cursor image which has more
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
     * colors than the system supports.  It is therefore recommended that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
     * be called and an appropriate image used so no image conversion is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
     * @return    the maximum number of colors, or zero if custom cursors are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
     * supported by this Toolkit implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
    public int getMaximumCursorColors() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
            return Toolkit.getDefaultToolkit().getMaximumCursorColors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
     * Returns whether Toolkit supports this state for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
     * <code>Frame</code>s.  This method tells whether the <em>UI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
     * concept</em> of, say, maximization or iconification is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
     * supported.  It will always return false for "compound" states
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
     * like <code>Frame.ICONIFIED|Frame.MAXIMIZED_VERT</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
     * In other words, the rule of thumb is that only queries with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
     * single frame state constant as an argument are meaningful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
     * <p>Note that supporting a given concept is a platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
     * dependent feature. Due to native limitations the Toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
     * object may report a particular state as supported, however at
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
     * the same time the Toolkit object will be unable to apply the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
     * state to a given frame.  This circumstance has two following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
     * consequences:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
     * <li>Only the return value of {@code false} for the present
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * method actually indicates that the given state is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * supported. If the method returns {@code true} the given state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * may still be unsupported and/or unavailable for a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     * frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
     * <li>The developer should consider examining the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
     * {@link java.awt.event.WindowEvent#getNewState} method of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
     * {@code WindowEvent} received through the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
     * java.awt.event.WindowStateListener}, rather than assuming
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
     * that the state given to the {@code setExtendedState()} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
     * will be definitely applied. For more information see the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
     * documentation for the {@link Frame#setExtendedState} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
     * @param state one of named frame state constants.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
     * @return <code>true</code> is this frame state is supported by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
     *     this Toolkit implementation, <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
     * @exception HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
     *     if <code>GraphicsEnvironment.isHeadless()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
     *     returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
     * @see java.awt.Window#addWindowStateListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
     * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
    public boolean isFrameStateSupported(int state)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
        throws HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        if (GraphicsEnvironment.isHeadless()){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
                isFrameStateSupported(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
            return (state == Frame.NORMAL); // others are not guaranteed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
     * Support for I18N: any visible strings should be stored in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
     * sun.awt.resources.awt.properties.  The ResourceBundle is stored
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
     * here, so that only one copy is maintained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    private static ResourceBundle resources;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
     * Initialize JNI field and method ids
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
     * WARNING: This is a temporary workaround for a problem in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
     * way the AWT loads native libraries. A number of classes in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
     * AWT package have a native method, initIDs(), which initializes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
     * the JNI field and method ids used in the native portion of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
     * their implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
     * Since the use and storage of these ids is done by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
     * implementation libraries, the implementation of these method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
     * provided by the particular AWT implementations (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
     * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
     * problem is that this means that the native libraries must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
     * loaded by the java.* classes, which do not necessarily know the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
     * names of the libraries to load. A better way of doing this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
     * would be to provide a separate library which defines java.awt.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
     * initIDs, and exports the relevant symbols out to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
     * implementation libraries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
     * For now, we know it's done by the implementation, and we assume
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
     * that the name of the library is "awt".  -br.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
     * If you change loadLibraries(), please add the change to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
     * java.awt.image.ColorModel.loadLibraries(). Unfortunately,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
     * classes can be loaded in java.awt.image that depend on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
     * libawt and there is no way to call Toolkit.loadLibraries()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
     * directly.  -hung
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
    private static boolean loaded = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
    static void loadLibraries() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
        if (!loaded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
            java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
                          new sun.security.action.LoadLibraryAction("awt"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
            loaded = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
        java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
                                 new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
                    resources =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
                        ResourceBundle.getBundle("sun.awt.resources.awt",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
                                                 CoreResourceBundleControl.getRBControlInstance());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
                } catch (MissingResourceException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
                    // No resource file; defaults will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
        // ensure that the proper libraries are loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
        loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        initAssistiveTechnologies();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
     * Gets a property with the specified key and default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
     * This method returns defaultValue if the property is not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
    public static String getProperty(String key, String defaultValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
        if (resources != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
                return resources.getString(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
            catch (MissingResourceException e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
        return defaultValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
     * Get the application's or applet's EventQueue instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
     * Depending on the Toolkit implementation, different EventQueues
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
     * may be returned for different applets.  Applets should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
     * therefore not assume that the EventQueue instance returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
     * by this method will be shared by other applets or the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
     * <p>First, if there is a security manager, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
     * <code>checkAwtEventQueueAccess</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
     * method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
     * If  the default implementation of <code>checkAwtEventQueueAccess</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
     * is used (that is, that method is not overriden), then this results in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
     * a call to the security manager's <code>checkPermission</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
     * with an <code>AWTPermission("accessEventQueue")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
     * @return    the <code>EventQueue</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
     * @throws  SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
     *          if a security manager exists and its <code>{@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
     *          java.lang.SecurityManager#checkAwtEventQueueAccess}</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
     *          method denies access to the <code>EventQueue</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
     * @see     java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
    public final EventQueue getSystemEventQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
          security.checkAwtEventQueueAccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
        return getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
     * Gets the application's or applet's <code>EventQueue</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
     * instance, without checking access.  For security reasons,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
     * this can only be called from a <code>Toolkit</code> subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
     * @return the <code>EventQueue</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
    protected abstract EventQueue getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
    /* Accessor method for use by AWT package routines. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    static EventQueue getEventQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
        return getDefaultToolkit().getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
     * Creates the peer for a DragSourceContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
     * Always throws InvalidDndOperationException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
     * GraphicsEnvironment.isHeadless() returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
    public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
     * Creates a concrete, platform dependent, subclass of the abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
     * DragGestureRecognizer class requested, and associates it with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
     * DragSource, Component and DragGestureListener specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
     * subclasses should override this to provide their own implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
     * @param abstractRecognizerClass The abstract class of the required recognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
     * @param ds                      The DragSource
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
     * @param c                       The Component target for the DragGestureRecognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
     * @param srcActions              The actions permitted for the gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
     * @param dgl                     The DragGestureListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
     * @return the new object or null.  Always returns null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
     * GraphicsEnvironment.isHeadless() returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
    public <T extends DragGestureRecognizer> T
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
        createDragGestureRecognizer(Class<T> abstractRecognizerClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
                                    DragSource ds, Component c, int srcActions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
                                    DragGestureListener dgl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
     * Obtains a value for the specified desktop property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
     * A desktop property is a uniquely named value for a resource that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
     * is Toolkit global in nature. Usually it also is an abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
     * representation for an underlying platform dependent desktop setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
     * For more information on desktop properties supported by the AWT see
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
     * <a href="doc-files/DesktopProperties.html">AWT Desktop Properties</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
    public final synchronized Object getDesktopProperty(String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
        // better to override this method but it is declared final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
            return ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
                .getDesktopProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
        if (desktopProperties.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
            initializeDesktopProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
        Object value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
        // This property should never be cached
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
        if (propertyName.equals("awt.dynamicLayoutSupported")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
            value = lazilyLoadDesktopProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
            return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
        value = desktopProperties.get(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
        if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
            value = lazilyLoadDesktopProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
            if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
                setDesktopProperty(propertyName, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
        /* for property "awt.font.desktophints" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
        if (value instanceof RenderingHints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
            value = ((RenderingHints)value).clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
     * Sets the named desktop property to the specified value and fires a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
     * property change event to notify any listeners that the value has changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
    protected final void setDesktopProperty(String name, Object newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
        // better to override this method but it is declared final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
            ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
                .setDesktopProperty(name, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
        Object oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
            oldValue = desktopProperties.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
            desktopProperties.put(name, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
7009
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1821
        // Don't fire change event if old and new values are null.
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1822
        // It helps to avoid recursive resending of WM_THEMECHANGED
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1823
        if (oldValue != null || newValue != null) {
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1824
            desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1825
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
     * an opportunity to lazily evaluate desktop property values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
    protected Object lazilyLoadDesktopProperty(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
     * initializeDesktopProperties
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
    protected void initializeDesktopProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
     * Adds the specified property change listener for the named desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
     * property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
     * If pcl is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
     * @param   name The name of the property to listen for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
     * @param   pcl The property change listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
     * @since   1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
    public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
        desktopPropsSupport.addPropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
     * Removes the specified property change listener for the named
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
     * desktop property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
     * If pcl is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
     * @param   name The name of the property to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
     * @param   pcl The property change listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
     * @since   1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
    public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
        desktopPropsSupport.removePropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
     * Returns an array of all the property change listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
     * registered on this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
     * @return all of this toolkit's <code>PropertyChangeListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
     *         or an empty array if no property change
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
    public PropertyChangeListener[] getPropertyChangeListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
        return desktopPropsSupport.getPropertyChangeListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
     * Returns an array of all the <code>PropertyChangeListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
     * associated with the named property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
     * @param  propertyName the named property
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
     * @return all of the <code>PropertyChangeListener</code>s associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
     *         the named property or an empty array if no such listeners have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
     *         been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
        return desktopPropsSupport.getPropertyChangeListeners(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
    protected final Map<String,Object> desktopProperties =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
            new HashMap<String,Object>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
    protected final PropertyChangeSupport desktopPropsSupport =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
            Toolkit.createPropertyChangeSupport(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
     * Returns whether the always-on-top mode is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
     * To detect whether the always-on-top mode is supported for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
     * particular Window, use {@link Window#isAlwaysOnTopSupported}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
     * @return <code>true</code>, if current toolkit supports the always-on-top mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
     *     otherwise returns <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
     * @see Window#isAlwaysOnTopSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
     * @see Window#setAlwaysOnTop(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
    public boolean isAlwaysOnTopSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
     * Returns whether the given modality type is supported by this toolkit. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
     * a dialog with unsupported modality type is created, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
     * <code>Dialog.ModalityType.MODELESS</code> is used instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
     * @param modalityType modality type to be checked for support by this toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
     * @return <code>true</code>, if current toolkit supports given modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
     *     type, <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
     * @see java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
    public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
     * Returns whether the given modal exclusion type is supported by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
     * toolkit. If an unsupported modal exclusion type property is set on a window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
     * then <code>Dialog.ModalExclusionType.NO_EXCLUDE</code> is used instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
     * @param modalExclusionType modal exclusion type to be checked for support by this toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
     * @return <code>true</code>, if current toolkit supports given modal exclusion
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
     *     type, <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
     * @see java.awt.Dialog.ModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
     * @see java.awt.Window#getModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
     * @see java.awt.Window#setModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
    public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 1962
diff changeset
  1950
    private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Toolkit");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
    private static final int LONG_BITS = 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
    private int[] calls = new int[LONG_BITS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
    private static volatile long enabledOnToolkitMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
    private AWTEventListener eventListener = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
    private WeakHashMap listener2SelectiveListener = new WeakHashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
     * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
     * if the listener is proxied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
    static private AWTEventListener deProxyAWTEventListener(AWTEventListener l)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
        AWTEventListener localL = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
        if (localL == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
        // if user passed in a AWTEventListenerProxy object, extract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
        // the listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
        if (l instanceof AWTEventListenerProxy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
            localL = ((AWTEventListenerProxy)l).getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
        return localL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
     * Adds an AWTEventListener to receive all AWTEvents dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
     * system-wide that conform to the given <code>eventMask</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
     * First, if there is a security manager, its <code>checkPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
     * <code>AWTPermission("listenToAllAWTEvents")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
     * <code>eventMask</code> is a bitmask of event types to receive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
     * It is constructed by bitwise OR-ing together the event masks
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
     * defined in <code>AWTEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
     * Note:  event listener use is not recommended for normal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
     * application use, but are intended solely to support special
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
     * purpose facilities including support for accessibility,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
     * event record/playback, and diagnostic tracing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
     * If listener is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
     * @param    listener   the event listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
     * @param    eventMask  the bitmask of event types to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
     *        <code>checkPermission</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
     * @see      #getAWTEventListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
     * @since    1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
    public void addAWTEventListener(AWTEventListener listener, long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
        AWTEventListener localL = deProxyAWTEventListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
        if (localL == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
        if (security != null) {
3956
2586d23078e4 6854954: Eliminate static dependency on java.awt.AWTPermission
alanb
parents: 1962
diff changeset
  2019
          security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
            SelectiveAWTEventListener selectiveListener =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
            if (selectiveListener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
                // Create a new selectiveListener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
                selectiveListener = new SelectiveAWTEventListener(localL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
                                                                 eventMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
                listener2SelectiveListener.put(localL, selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
                eventListener = ToolkitEventMulticaster.add(eventListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
                                                            selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
            // OR the eventMask into the selectiveListener's event mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
            selectiveListener.orEventMasks(eventMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
            enabledOnToolkitMask |= eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
            long mask = eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
            for (int i=0; i<LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
                // If no bits are set, break out of loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
                if (mask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
                if ((mask & 1L) != 0) {  // Always test bit 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
                    calls[i]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
                mask >>>= 1;  // Right shift, fill with zeros on left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
     * Removes an AWTEventListener from receiving dispatched AWTEvents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
     * First, if there is a security manager, its <code>checkPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
     * <code>AWTPermission("listenToAllAWTEvents")</code> permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
     * Note:  event listener use is not recommended for normal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
     * application use, but are intended solely to support special
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
     * purpose facilities including support for accessibility,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
     * event record/playback, and diagnostic tracing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
     * If listener is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
     * @param    listener   the event listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
     *        <code>checkPermission</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
     * @see      #getAWTEventListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
     * @since    1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
    public void removeAWTEventListener(AWTEventListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
        AWTEventListener localL = deProxyAWTEventListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
        if (listener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
        if (security != null) {
3956
2586d23078e4 6854954: Eliminate static dependency on java.awt.AWTPermission
alanb
parents: 1962
diff changeset
  2088
            security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
            SelectiveAWTEventListener selectiveListener =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
            if (selectiveListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
                listener2SelectiveListener.remove(localL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
                int[] listenerCalls = selectiveListener.getCalls();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
                for (int i=0; i<LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
                    calls[i] -= listenerCalls[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
                    assert calls[i] >= 0: "Negative Listeners count";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
                    if (calls[i] == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
                        enabledOnToolkitMask &= ~(1L<<i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
            eventListener = ToolkitEventMulticaster.remove(eventListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
            (selectiveListener == null) ? localL : selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
    static boolean enabledOnToolkit(long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
        return (enabledOnToolkitMask & eventMask) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
    synchronized int countAWTEventListeners(long eventMask) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 1962
diff changeset
  2117
        if (log.isLoggable(PlatformLogger.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
            if (eventMask == 0) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 1962
diff changeset
  2119
                log.fine("Assertion (eventMask != 0) failed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
        int ci = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
        for (; eventMask != 0; eventMask >>>= 1, ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
        ci--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
        return calls[ci];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
     * Returns an array of all the <code>AWTEventListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
     * registered on this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
     * If there is a security manager, its {@code checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
     * Listeners can be returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
     * within <code>AWTEventListenerProxy</code> objects, which also contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
     * the event mask for the given listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
     * Note that listener objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
     * added multiple times appear only once in the returned array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
     * @return all of the <code>AWTEventListener</code>s or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
     *         array if no listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
     *        <code>checkPermission</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
    public AWTEventListener[] getAWTEventListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
        if (security != null) {
3956
2586d23078e4 6854954: Eliminate static dependency on java.awt.AWTPermission
alanb
parents: 1962
diff changeset
  2159
            security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
            AWTEventListener[] ret = new AWTEventListener[la.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
            for (int i = 0; i < la.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
                AWTEventListener tempL = sael.getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
                //assert tempL is not an AWTEventListenerProxy - we should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
                // have weeded them all out
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
                // don't want to wrap a proxy inside a proxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
                ret[i] = new AWTEventListenerProxy(sael.getEventMask(), tempL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
            return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
     * Returns an array of all the <code>AWTEventListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
     * registered on this toolkit which listen to all of the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
     * types specified in the {@code eventMask} argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
     * If there is a security manager, its {@code checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
     * Listeners can be returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
     * within <code>AWTEventListenerProxy</code> objects, which also contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
     * the event mask for the given listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
     * Note that listener objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
     * added multiple times appear only once in the returned array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
     * @param  eventMask the bitmask of event types to listen for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
     * @return all of the <code>AWTEventListener</code>s registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
     *         on this toolkit for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
     *         event types, or an empty array if no such listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
     *         are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
     *        if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
     *        <code>checkPermission</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
    public AWTEventListener[] getAWTEventListeners(long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
        if (security != null) {
3956
2586d23078e4 6854954: Eliminate static dependency on java.awt.AWTPermission
alanb
parents: 1962
diff changeset
  2211
            security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
            java.util.List list = new ArrayList(la.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
            for (int i = 0; i < la.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                if ((sael.getEventMask() & eventMask) == eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
                    //AWTEventListener tempL = sael.getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
                    list.add(new AWTEventListenerProxy(sael.getEventMask(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
                                                       sael.getListener()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
            return (AWTEventListener[])list.toArray(new AWTEventListener[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
     * This method notifies any AWTEventListeners that an event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
     * is about to be dispatched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
     * @param theEvent the event which will be dispatched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
    void notifyAWTEventListeners(AWTEvent theEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
        // better to override this method but it is declared package private.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
            ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
                .notifyAWTEventListeners(theEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
        AWTEventListener eventListener = this.eventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
        if (eventListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
            eventListener.eventDispatched(theEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
    static private class ToolkitEventMulticaster extends AWTEventMulticaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
        implements AWTEventListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
        // Implementation cloned from AWTEventMulticaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
        ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
            super(a, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
        static AWTEventListener add(AWTEventListener a,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
                                    AWTEventListener b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
            if (a == null)  return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
            if (b == null)  return a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
            return new ToolkitEventMulticaster(a, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
        static AWTEventListener remove(AWTEventListener l,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
                                       AWTEventListener oldl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
            return (AWTEventListener) removeInternal(l, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
        // #4178589: must overload remove(EventListener) to call our add()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
        // instead of the static addInternal() so we allocate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
        // ToolkitEventMulticaster instead of an AWTEventMulticaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
        // Note: this method is called by AWTEventListener.removeInternal(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
        // so its method signature must match AWTEventListener.remove().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2278
        protected EventListener remove(EventListener oldl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
            if (oldl == a)  return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
            if (oldl == b)  return a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
            AWTEventListener a2 = (AWTEventListener)removeInternal(a, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
            AWTEventListener b2 = (AWTEventListener)removeInternal(b, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
            if (a2 == a && b2 == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
                return this;    // it's not here
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2286
            return add(a2, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
        public void eventDispatched(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2290
            ((AWTEventListener)a).eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
            ((AWTEventListener)b).eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
    private class SelectiveAWTEventListener implements AWTEventListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
        AWTEventListener listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
        private long eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
        // This array contains the number of times to call the eventlistener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
        // for each event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
        int[] calls = new int[Toolkit.LONG_BITS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
        public AWTEventListener getListener() {return listener;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
        public long getEventMask() {return eventMask;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
        public int[] getCalls() {return calls;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
        public void orEventMasks(long mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
            eventMask |= mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
            // For each event bit set in mask, increment its call count.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
            for (int i=0; i<Toolkit.LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
                // If no bits are set, break out of loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
                if (mask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
                if ((mask & 1L) != 0) {  // Always test bit 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
                    calls[i]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
                mask >>>= 1;  // Right shift, fill with zeros on left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
        SelectiveAWTEventListener(AWTEventListener l, long mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
            listener = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
            eventMask = mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
        public void eventDispatched(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
            long eventBit = 0; // Used to save the bit of the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
            if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
                 event.id >= ComponentEvent.COMPONENT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2330
                 event.id <= ComponentEvent.COMPONENT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2331
             || ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2332
                 event.id >= ContainerEvent.CONTAINER_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2333
                 event.id <= ContainerEvent.CONTAINER_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
             || ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
                 event.id >= FocusEvent.FOCUS_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2336
                 event.id <= FocusEvent.FOCUS_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2337
             || ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
                 event.id >= KeyEvent.KEY_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2339
                 event.id <= KeyEvent.KEY_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2340
             || ((eventBit = eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2341
                 event.id == MouseEvent.MOUSE_WHEEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2342
             || ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2343
                 (event.id == MouseEvent.MOUSE_MOVED ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2344
                  event.id == MouseEvent.MOUSE_DRAGGED))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2345
             || ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2346
                 event.id != MouseEvent.MOUSE_MOVED &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2347
                 event.id != MouseEvent.MOUSE_DRAGGED &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2348
                 event.id != MouseEvent.MOUSE_WHEEL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2349
                 event.id >= MouseEvent.MOUSE_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2350
                 event.id <= MouseEvent.MOUSE_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
             || ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
                 (event.id >= WindowEvent.WINDOW_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
                 event.id <= WindowEvent.WINDOW_LAST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
             || ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
                 event.id >= ActionEvent.ACTION_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
                 event.id <= ActionEvent.ACTION_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
             || ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
                 event.id >= AdjustmentEvent.ADJUSTMENT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
                 event.id <= AdjustmentEvent.ADJUSTMENT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
             || ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
                 event.id >= ItemEvent.ITEM_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
                 event.id <= ItemEvent.ITEM_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
             || ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
                 event.id >= TextEvent.TEXT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
                 event.id <= TextEvent.TEXT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
             || ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
                 event.id >= InputMethodEvent.INPUT_METHOD_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
                 event.id <= InputMethodEvent.INPUT_METHOD_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
             || ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
                 event.id >= PaintEvent.PAINT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
                 event.id <= PaintEvent.PAINT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
             || ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
                 event.id >= InvocationEvent.INVOCATION_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
                 event.id <= InvocationEvent.INVOCATION_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
             || ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
                 event.id == HierarchyEvent.HIERARCHY_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
             || ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
                 (event.id == HierarchyEvent.ANCESTOR_MOVED ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
                  event.id == HierarchyEvent.ANCESTOR_RESIZED))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
             || ((eventBit = eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
                 event.id == WindowEvent.WINDOW_STATE_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
             || ((eventBit = eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
                 (event.id == WindowEvent.WINDOW_GAINED_FOCUS ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
                  event.id == WindowEvent.WINDOW_LOST_FOCUS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
                || ((eventBit = eventMask & sun.awt.SunToolkit.GRAB_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
                    (event instanceof sun.awt.UngrabEvent))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
                // Get the index of the call count for this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2388
                // Instead of using Math.log(...) we will calculate it with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
                // bit shifts. That's what previous implementation looked like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
                // int ci = (int) (Math.log(eventBit)/Math.log(2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
                int ci = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
                for (long eMask = eventBit; eMask != 0; eMask >>>= 1, ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
                ci--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2396
                // Call the listener as many times as it was added for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2397
                // event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2398
                for (int i=0; i<calls[ci]; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2399
                    listener.eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2400
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2401
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2406
     * Returns a map of visual attributes for the abstract level description
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2407
     * of the given input method highlight, or null if no mapping is found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2408
     * The style field of the input method highlight is ignored. The map
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2409
     * returned is unmodifiable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2410
     * @param highlight input method highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2411
     * @return style attribute map, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2412
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2413
     *     <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2414
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2415
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2417
    public abstract Map<java.awt.font.TextAttribute,?>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
        mapInputMethodHighlight(InputMethodHighlight highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
    private static PropertyChangeSupport createPropertyChangeSupport(Toolkit toolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
        if (toolkit instanceof SunToolkit || toolkit instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2423
            return new DesktopPropertyChangeSupport(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2424
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2425
            return new PropertyChangeSupport(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2429
    private static class DesktopPropertyChangeSupport extends PropertyChangeSupport {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2430
        private static final StringBuilder PROP_CHANGE_SUPPORT_KEY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2431
                new StringBuilder("desktop property change support key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2432
        private final Object source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2434
        public DesktopPropertyChangeSupport(Object sourceBean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2435
            super(sourceBean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2436
            source = sourceBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2437
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2439
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2440
        public synchronized void addPropertyChangeListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2441
                String propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2442
                PropertyChangeListener listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2443
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2444
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2445
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2446
            if (null == pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2447
                pcs = new PropertyChangeSupport(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2448
                AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2450
            pcs.addPropertyChangeListener(propertyName, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2453
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2454
        public synchronized void removePropertyChangeListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2455
                String propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2456
                PropertyChangeListener listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2457
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2458
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2459
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2460
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2461
                pcs.removePropertyChangeListener(propertyName, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2463
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2465
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2466
        public synchronized PropertyChangeListener[] getPropertyChangeListeners()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2467
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2468
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2469
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2470
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2471
                return pcs.getPropertyChangeListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2472
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2473
                return new PropertyChangeListener[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2476
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2477
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2478
        public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2479
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2480
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2481
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2482
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2483
                return pcs.getPropertyChangeListeners(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2484
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2485
                return new PropertyChangeListener[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2486
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2488
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2489
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2490
        public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2491
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2492
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2493
            if (null == pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2494
                pcs = new PropertyChangeSupport(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2495
                AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2496
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2497
            pcs.addPropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2500
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2501
        public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2502
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2503
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2504
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2505
                pcs.removePropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2506
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2507
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2509
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2510
         * we do expect that all other fireXXX() methods of java.beans.PropertyChangeSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2511
         * use this method.  If this will be changed we will need to change this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2512
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2513
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2514
        public void firePropertyChange(final PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2515
            Object oldValue = evt.getOldValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2516
            Object newValue = evt.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2517
            String propertyName = evt.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2518
            if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2519
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2520
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2521
            Runnable updater = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2522
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2523
                    PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2524
                            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2525
                    if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2526
                        pcs.firePropertyChange(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2527
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2528
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2529
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2530
            final AppContext currentAppContext = AppContext.getAppContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2531
            for (AppContext appContext : AppContext.getAppContexts()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2532
                if (null == appContext || appContext.isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2533
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2534
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2535
                if (currentAppContext == appContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2536
                    updater.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2537
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2538
                    final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2539
                    SunToolkit.postEvent(appContext, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2540
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2541
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2542
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2543
    }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2544
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2545
    /**
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2546
    * Reports whether events from extra mouse buttons are allowed to be processed and posted into
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2547
    * {@code EventQueue}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2548
    * <br>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2549
    * To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2550
    * property before the {@code Toolkit} class initialization. This setting could be done on the application
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2551
    * startup by the following command:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2552
    * <pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2553
    * java -Dsun.awt.enableExtraMouseButtons=false Application
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2554
    * </pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2555
    * Alternatively, the property could be set in the application by using the following code:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2556
    * <pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2557
    * System.setProperty("sun.awt.enableExtraMouseButtons", "true");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2558
    * </pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2559
    * before the {@code Toolkit} class initialization.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2560
    * If not set by the time of the {@code Toolkit} class initialization, this property will be
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2561
    * initialized with {@code true}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2562
    * Changing this value after the {@code Toolkit} class initialization will have no effect.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2563
    * <p>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2564
    * The current value could be queried by using the
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2565
    * {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2566
    * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2567
    * @return {@code true} if events from extra mouse buttons are allowed to be processed and posted;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2568
    *         {@code false} otherwise
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2569
    * @see System#getProperty(String propertyName)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2570
    * @see System#setProperty(String propertyName, String value)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2571
    * @see java.awt.EventQueue
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2572
    * @since 1.7
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2573
     */
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2574
    public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2575
        return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2576
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2577
}