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