-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathToolkit.java
More file actions
2434 lines (2324 loc) · 106 KB
/
Copy pathToolkit.java
File metadata and controls
2434 lines (2324 loc) · 106 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Some portions of this file have been modified by Robert Hanson hansonr.at.stolaf.edu 2012-2017
* for use in SwingJS via transpilation into JavaScript using Java2Script.
*
* Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jsjava.awt;
import java.awt.AWTPermission;
import java.awt.HeadlessException;
import java.awt.TextComponent;
import java.net.URL;
import java.util.ArrayList;
import java.util.EventListener;
import java.util.HashMap;
import java.util.Map;
import java.util.MissingResourceException;
import jsjava.awt.datatransfer.Clipboard;
import jsjava.awt.dnd.DragGestureEvent;
import jsjava.awt.dnd.DragGestureListener;
import jsjava.awt.dnd.DragGestureRecognizer;
import jsjava.awt.dnd.DragSource;
import jsjava.awt.dnd.InvalidDnDOperationException;
import jsjava.awt.dnd.peer.DragSourceContextPeer;
import jsjava.awt.event.AWTEventListener;
import jsjava.awt.event.AWTEventListenerProxy;
import jsjava.awt.event.ActionEvent;
import jsjava.awt.event.AdjustmentEvent;
import jsjava.awt.event.ComponentEvent;
import jsjava.awt.event.ContainerEvent;
import jsjava.awt.event.FocusEvent;
import jsjava.awt.event.HierarchyEvent;
import jsjava.awt.event.InputMethodEvent;
import jsjava.awt.event.InvocationEvent;
import jsjava.awt.event.ItemEvent;
import jsjava.awt.event.KeyEvent;
import jsjava.awt.event.MouseEvent;
import jsjava.awt.event.PaintEvent;
import jsjava.awt.event.TextEvent;
import jsjava.awt.event.WindowEvent;
import jsjava.awt.image.ColorModel;
import jsjava.awt.image.ImageObserver;
import jsjava.awt.image.ImageProducer;
import jsjava.awt.peer.FramePeer;
import jsjava.awt.peer.LightweightPeer;
import jsjava.awt.peer.PanelPeer;
import jsjava.awt.peer.WindowPeer;
import jsjava.beans.PropertyChangeListener;
import jsjava.beans.PropertyChangeSupport;
import jsjava.util.ResourceBundle;
import jssun.awt.NullComponentPeer;
import swingjs.JSToolkit;
//import java.util.WeakHashMap;
/**
* This class is the abstract superclass of all actual
* implementations of the Abstract Window Toolkit. Subclasses of
* <code>Toolkit</code> are used to bind the various components
* to particular native toolkit implementations.
* <p>
* Many GUI operations may be performed asynchronously. This
* means that if you set the state of a component, and then
* immediately query the state, the returned value may not yet
* reflect the requested change. This includes, but is not
* limited to:
* <ul>
* <li>Scrolling to a specified position.
* <br>For example, calling <code>ScrollPane.setScrollPosition</code>
* and then <code>getScrollPosition</code> may return an incorrect
* value if the original request has not yet been processed.
* <p>
* <li>Moving the focus from one component to another.
* <br>For more information, see
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#transferTiming">Timing
* Focus Transfers</a>, a section in
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing
* Tutorial</a>.
* <p>
* <li>Making a top-level container visible.
* <br>Calling <code>setVisible(true)</code> on a <code>Window</code>,
* <code>Frame</code> or <code>Dialog</code> may occur
* asynchronously.
* <p>
* <li>Setting the size or location of a top-level container.
* <br>Calls to <code>setSize</code>, <code>setBounds</code> or
* <code>setLocation</code> on a <code>Window</code>,
* <code>Frame</code> or <code>Dialog</code> are forwarded
* to the underlying window management system and may be
* ignored or modified. See {@link jsjava.awt.Window} for
* more information.
* </ul>
* <p>
* Most applications should not call any of the methods in this
* class directly. The methods defined by <code>Toolkit</code> are
* the "glue" that joins the platform-independent classes in the
* <code>java.awt</code> package with their counterparts in
* <code>java.awt.peer</code>. Some methods defined by
* <code>Toolkit</code> query the native operating system directly.
*
* @author Sami Shaio
* @author Arthur van Hoff
* @author Fred Ecks
* @since JDK1.0
*/
public abstract class Toolkit {
// SwingJS note: Most of these are AWT classes that we do not need to worry about
// because we are not allowing the heavyweights from AWT, but we do need
// PanelPeer, because our RootPanel extends Panel.
// /**
// * Creates this toolkit's implementation of the <code>Desktop</code>
// * using the specified peer interface.
// * @param target the desktop to be implemented
// * @return this toolkit's implementation of the <code>Desktop</code>
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Desktop
// * @see jsjava.awt.peer.DesktopPeer
// * @since 1.6
// */
// protected abstract DesktopPeer createDesktopPeer(Desktop target)
// ;
//
//
// /**
// * Creates this toolkit's implementation of <code>Button</code> using
// * the specified peer interface.
// * @param target the button to be implemented.
// * @return this toolkit's implementation of <code>Button</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Button
// * @see jsjava.awt.peer.ButtonPeer
// */
// protected abstract ButtonPeer createButton(Button target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>TextField</code> using
// * the specified peer interface.
// * @param target the text field to be implemented.
// * @return this toolkit's implementation of <code>TextField</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.TextField
// * @see jsjava.awt.peer.TextFieldPeer
// */
// protected abstract TextFieldPeer createTextField(TextField target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>Label</code> using
// * the specified peer interface.
// * @param target the label to be implemented.
// * @return this toolkit's implementation of <code>Label</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Label
// * @see jsjava.awt.peer.LabelPeer
// */
// protected abstract LabelPeer createLabel(Label target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>List</code> using
// * the specified peer interface.
// * @param target the list to be implemented.
// * @return this toolkit's implementation of <code>List</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.List
// * @see jsjava.awt.peer.ListPeer
// */
// protected abstract ListPeer createList(java.awt.List target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>Checkbox</code> using
// * the specified peer interface.
// * @param target the check box to be implemented.
// * @return this toolkit's implementation of <code>Checkbox</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Checkbox
// * @see jsjava.awt.peer.CheckboxPeer
// */
// protected abstract CheckboxPeer createCheckbox(Checkbox target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>Scrollbar</code> using
// * the specified peer interface.
// * @param target the scroll bar to be implemented.
// * @return this toolkit's implementation of <code>Scrollbar</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Scrollbar
// * @see jsjava.awt.peer.ScrollbarPeer
// */
// protected abstract ScrollbarPeer createScrollbar(Scrollbar target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>ScrollPane</code> using
// * the specified peer interface.
// * @param target the scroll pane to be implemented.
// * @return this toolkit's implementation of <code>ScrollPane</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.ScrollPane
// * @see jsjava.awt.peer.ScrollPanePeer
// * @since JDK1.1
// */
// protected abstract ScrollPanePeer createScrollPane(ScrollPane target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>TextArea</code> using
// * the specified peer interface.
// * @param target the text area to be implemented.
// * @return this toolkit's implementation of <code>TextArea</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.TextArea
// * @see jsjava.awt.peer.TextAreaPeer
// */
// protected abstract TextAreaPeer createTextArea(TextArea target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>Choice</code> using
// * the specified peer interface.
// * @param target the choice to be implemented.
// * @return this toolkit's implementation of <code>Choice</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Choice
// * @see jsjava.awt.peer.ChoicePeer
// */
// protected abstract ChoicePeer createChoice(Choice target)
// ;
//
/**
* Creates this toolkit's implementation of <code>Frame</code> using
* the specified peer interface.
* @param target the frame to be implemented.
* @return this toolkit's implementation of <code>Frame</code>.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @see jsjava.awt.Frame
* @see jsjava.awt.peer.FramePeer
*/
protected abstract FramePeer createFrame(Frame target);
//
// /**
// * Creates this toolkit's implementation of <code>Canvas</code> using
// * the specified peer interface.
// * @param target the canvas to be implemented.
// * @return this toolkit's implementation of <code>Canvas</code>.
// * @see jsjava.awt.Canvas
// * @see jsjava.awt.peer.CanvasPeer
// */
// protected abstract CanvasPeer createCanvas(Canvas target);
//
/**
* Creates this toolkit's implementation of <code>Panel</code> using
* the specified peer interface.
* @param target the panel to be implemented.
* @return this toolkit's implementation of <code>Panel</code>.
* @see jsjava.awt.Panel
* @see jsjava.awt.peer.PanelPeer
*/
protected abstract PanelPeer createPanel(Panel target);
/**
* Creates this toolkit's implementation of <code>Window</code> using
* the specified peer interface.
* @param target the window to be implemented.
* @return this toolkit's implementation of <code>Window</code>.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @see jsjava.awt.Window
* @see jsjava.awt.peer.WindowPeer
*/
protected abstract WindowPeer createWindow(Window target);
/**
* Creates this toolkit's implementation of <code>Dialog</code> using
* the specified peer interface.
* @param target the dialog to be implemented.
* @return this toolkit's implementation of <code>Dialog</code>.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @see jsjava.awt.Dialog
* @see jsjava.awt.peer.DialogPeer
*/
protected abstract jsjava.awt.peer.DialogPeer createDialog(Dialog target)
;
// /**
// * Creates this toolkit's implementation of <code>MenuBar</code> using
// * the specified peer interface.
// * @param target the menu bar to be implemented.
// * @return this toolkit's implementation of <code>MenuBar</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.MenuBar
// * @see jsjava.awt.peer.MenuBarPeer
// */
// protected abstract MenuBarPeer createMenuBar(MenuBar target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>Menu</code> using
// * the specified peer interface.
// * @param target the menu to be implemented.
// * @return this toolkit's implementation of <code>Menu</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.Menu
// * @see jsjava.awt.peer.MenuPeer
// */
// protected abstract MenuPeer createMenu(Menu target)
// ;
// /**
// * Creates this toolkit's implementation of <code>PopupMenu</code> using
// * the specified peer interface.
// * @param target the popup menu to be implemented.
// * @return this toolkit's implementation of <code>PopupMenu</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.PopupMenu
// * @see jsjava.awt.peer.PopupMenuPeer
// * @since JDK1.1
// */
// protected abstract PopupMenuPeer createPopupMenu(PopupMenu target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>MenuItem</code> using
// * the specified peer interface.
// * @param target the menu item to be implemented.
// * @return this toolkit's implementation of <code>MenuItem</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.MenuItem
// * @see jsjava.awt.peer.MenuItemPeer
// */
// protected abstract MenuItemPeer createMenuItem(MenuItem target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>FileDialog</code> using
// * the specified peer interface.
// * @param target the file dialog to be implemented.
// * @return this toolkit's implementation of <code>FileDialog</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.FileDialog
// * @see jsjava.awt.peer.FileDialogPeer
// */
// protected abstract FileDialogPeer createFileDialog(FileDialog target)
// ;
//
// /**
// * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using
// * the specified peer interface.
// * @param target the checkbox menu item to be implemented.
// * @return this toolkit's implementation of <code>CheckboxMenuItem</code>.
// * @exception HeadlessException if GraphicsEnvironment.isHeadless()
// * returns true
// * @see jsjava.awt.GraphicsEnvironment#isHeadless
// * @see jsjava.awt.CheckboxMenuItem
// * @see jsjava.awt.peer.CheckboxMenuItemPeer
// */
// protected abstract CheckboxMenuItemPeer createCheckboxMenuItem(
// CheckboxMenuItem target) ;
//
// /**
// * Obtains this toolkit's implementation of helper class for
// * <code>MouseInfo</code> operations.
// * @return this toolkit's implementation of helper for <code>MouseInfo</code>
// * @throws UnsupportedOperationException if this operation is not implemented
// * @see jsjava.awt.peer.MouseInfoPeer
// * @see jsjava.awt.MouseInfo
// * @since 1.5
// */
// protected MouseInfoPeer getMouseInfoPeer() {
// throw new UnsupportedOperationException("Not implemented");
// }
//
private static LightweightPeer lightweightMarker;
/**
* Creates a peer for a component or container. This peer is windowless
* and allows the Component and Container classes to be extended directly
* to create windowless components that are defined entirely in java.
*
* @param target The Component to be created.
*/
protected LightweightPeer createComponent(Component target) {
if (lightweightMarker == null) {
lightweightMarker = new NullComponentPeer();
}
return lightweightMarker;
}
//
// /**
// * Creates this toolkit's implementation of <code>Font</code> using
// * the specified peer interface.
// * @param name the font to be implemented
// * @param style the style of the font, such as <code>PLAIN</code>,
// * <code>BOLD</code>, <code>ITALIC</code>, or a combination
// * @return this toolkit's implementation of <code>Font</code>
// * @see jsjava.awt.Font
// * @see jsjava.awt.peer.FontPeer
// * @see jsjava.awt.GraphicsEnvironment#getAllFonts
// * @deprecated see jsjava.awt.GraphicsEnvironment#getAllFonts
// */
// @Deprecated
// protected abstract FontPeer getFontPeer(String name, int style);
//
// The following method is called by the private method
// <code>updateSystemColors</code> in <code>SystemColor</code>.
/**
* Fills in the integer array that is supplied as an argument
* with the current system color values.
*
* @param systemColors an integer array.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @since JDK1.1
*/
protected void loadSystemColors(int[] systemColors)
{
}
/**
* Controls whether the layout of Containers is validated dynamically
* during resizing, or statically, after resizing is complete.
* Note that this feature is supported not on all platforms, and
* conversely, that this feature cannot be turned off on some platforms.
* On these platforms where dynamic layout during resizing is not supported
* (or is always supported), setting this property has no effect.
* Note that this feature can be set or unset as a property of the
* operating system or window manager on some platforms. On such
* platforms, the dynamic resize property must be set at the operating
* system or window manager level before this method can take effect.
* This method does not change support or settings of the underlying
* operating system or
* window manager. The OS/WM support can be
* queried using getDesktopProperty("awt.dynamicLayoutSupported") method.
*
* @param dynamic If true, Containers should re-layout their
* components as the Container is being resized. If false,
* the layout will be validated after resizing is completed.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see #isDynamicLayoutSet()
* @see #isDynamicLayoutActive()
* @see #getDesktopProperty(String propertyName)
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
public void setDynamicLayout(boolean dynamic)
{
}
/**
* Returns whether the layout of Containers is validated dynamically
* during resizing, or statically, after resizing is complete.
* Note: this method returns the value that was set programmatically;
* it does not reflect support at the level of the operating system
* or window manager for dynamic layout on resizing, or the current
* operating system or window manager settings. The OS/WM support can
* be queried using getDesktopProperty("awt.dynamicLayoutSupported").
*
* @return true if validation of Containers is done dynamically,
* false if validation is done after resizing is finished.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see #setDynamicLayout(boolean dynamic)
* @see #isDynamicLayoutActive()
* @see #getDesktopProperty(String propertyName)
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
protected boolean isDynamicLayoutSet()
{
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().isDynamicLayoutSet();
} else {
return false;
}
}
/**
* Returns whether dynamic layout of Containers on resize is
* currently active (both set in program
*, and supported
* by the underlying operating system and/or window manager).
* The OS/WM support can be queried using
* the getDesktopProperty("awt.dynamicLayoutSupported") method.
*
* @return true if dynamic layout of Containers on resize is
* currently active, false otherwise.
* @exception HeadlessException if the GraphicsEnvironment.isHeadless()
* method returns true
* @see #setDynamicLayout(boolean dynamic)
* @see #isDynamicLayoutSet()
* @see #getDesktopProperty(String propertyName)
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
public boolean isDynamicLayoutActive()
{
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().isDynamicLayoutActive();
} else {
return false;
}
}
/**
* Gets the size of the screen. On systems with multiple displays, the
* primary display is used. Multi-screen aware display dimensions are
* available from <code>GraphicsConfiguration</code> and
* <code>GraphicsDevice</code>.
* @return the size of this toolkit's screen, in pixels.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsConfiguration#getBounds
* @see jsjava.awt.GraphicsDevice#getDisplayMode
* @see jsjava.awt.GraphicsEnvironment#isHeadless
*/
public abstract Dimension getScreenSize()
;
/**
* Returns the screen resolution in dots-per-inch.
* @return this toolkit's screen resolution, in dots-per-inch.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
*/
public abstract int getScreenResolution()
;
/**
* Gets the insets of the screen.
* @param gc a <code>GraphicsConfiguration</code>
* @return the insets of this toolkit's screen, in pixels.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
public Insets getScreenInsets(GraphicsConfiguration gc)
{
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().getScreenInsets(gc);
} else {
return new Insets(0, 0, 0, 0);
}
}
/**
* Determines the color model of this toolkit's screen.
* <p>
* <code>ColorModel</code> is an abstract class that
* encapsulates the ability to translate between the
* pixel values of an image and its red, green, blue,
* and alpha components.
* <p>
* This toolkit method is called by the
* <code>getColorModel</code> method
* of the <code>Component</code> class.
* @return the color model of this toolkit's screen.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see jsjava.awt.GraphicsEnvironment#isHeadless
* @see jsjava.awt.image.ColorModel
* @see jsjava.awt.Component#getColorModel
*/
public abstract ColorModel getColorModel()
;
/**
* Returns the names of the available fonts in this toolkit.<p>
* For 1.1, the following font names are deprecated (the replacement
* name follows):
* <ul>
* <li>TimesRoman (use Serif)
* <li>Helvetica (use SansSerif)
* <li>Courier (use Monospaced)
* </ul><p>
* The ZapfDingbats fontname is also deprecated in 1.1 but the characters
* are defined in Unicode starting at 0x2700, and as of 1.1 Java supports
* those characters.
* @return the names of the available fonts in this toolkit.
* @deprecated see {@link jsjava.awt.GraphicsEnvironment#getAvailableFontFamilyNames()}
* @see jsjava.awt.GraphicsEnvironment#getAvailableFontFamilyNames()
*/
@Deprecated
public abstract String[] getFontList();
/**
* Gets the screen device metrics for rendering of the font.
* @param font a font
* @return the screen metrics of the specified font in this toolkit
* @deprecated As of JDK version 1.2, replaced by the <code>Font</code>
* method <code>getLineMetrics</code>.
* @see jsjava.awt.font.LineMetrics
* @see jsjava.awt.Font#getLineMetrics
* @see jsjava.awt.GraphicsEnvironment#getScreenDevices
*/
@Deprecated
public abstract FontMetrics getFontMetrics(Font font);
/**
* Synchronizes this toolkit's graphics state. Some window systems
* may do buffering of graphics events.
* <p>
* This method ensures that the display is up-to-date. It is useful
* for animation.
*/
public abstract void sync();
/**
* The default toolkit.
*/
private static Toolkit toolkit;
// /**
// * Used internally by the assistive technologies functions; set at
// * init time and used at load time
// */
// private static String atNames;
// /**
// * Initializes properties related to assistive technologies.
// * These properties are used both in the loadAssistiveProperties()
// * function below, as well as other classes in the jdk that depend
// * on the properties (such as the use of the screen_magnifier_present
// * property in Java2D hardware acceleration initialization). The
// * initialization of the properties must be done before the platform-
// * specific Toolkit class is instantiated so that all necessary
// * properties are set up properly before any classes dependent upon them
// * are initialized.
// */
// private static void initAssistiveTechnologies() {
//
// // Get accessibility properties
// final String sep = File.separator;
// final Properties properties = new Properties();
//
//
// atNames = (String)jsjava.security.AccessController.doPrivileged(
// new jsjava.security.PrivilegedAction() {
// public Object run() {
//
// // Try loading the per-user accessibility properties file.
// try {
// File propsFile = new File(
// System.getProperty("user.home") +
// sep + ".accessibility.properties");
// FileInputStream in =
// new FileInputStream(propsFile);
//
// // Inputstream has been buffered in Properties class
// properties.load(in);
// in.close();
// } catch (Exception e) {
// // Per-user accessibility properties file does not exist
// }
//
// // Try loading the system-wide accessibility properties
// // file only if a per-user accessibility properties
// // file does not exist or is empty.
// if (properties.size() == 0) {
// try {
// File propsFile = new File(
// System.getProperty("java.home") + sep + "lib" +
// sep + "accessibility.properties");
// FileInputStream in =
// new FileInputStream(propsFile);
//
// // Inputstream has been buffered in Properties class
// properties.load(in);
// in.close();
// } catch (Exception e) {
// // System-wide accessibility properties file does
// // not exist;
// }
// }
//
// // Get whether a screen magnifier is present. First check
// // the system property and then check the properties file.
// String magPresent = System.getProperty("javax.accessibility.screen_magnifier_present");
// if (magPresent == null) {
// magPresent = properties.getProperty("screen_magnifier_present", null);
// if (magPresent != null) {
// System.setProperty("javax.accessibility.screen_magnifier_present", magPresent);
// }
// }
//
// // Get the names of any assistive technolgies to load. First
// // check the system property and then check the properties
// // file.
// String classNames = System.getProperty("javax.accessibility.assistive_technologies");
// if (classNames == null) {
// classNames = properties.getProperty("assistive_technologies", null);
// if (classNames != null) {
// System.setProperty("javax.accessibility.assistive_technologies", classNames);
// }
// }
// return classNames;
// }
// });
// }
// /**
// * Loads additional classes into the VM, using the property
// * 'assistive_technologies' specified in the Sun reference
// * implementation by a line in the 'accessibility.properties'
// * file. The form is "assistive_technologies=..." where
// * the "..." is a comma-separated list of assistive technology
// * classes to load. Each class is loaded in the order given
// * and a single instance of each is created using
// * Class.forName(class).newInstance(). All errors are handled
// * via an AWTError exception.
// *
// * <p>The assumption is made that assistive technology classes are supplied
// * as part of INSTALLED (as opposed to: BUNDLED) extensions or specified
// * on the class path
// * (and therefore can be loaded using the class loader returned by
// * a call to <code>ClassLoader.getSystemClassLoader</code>, whose
// * delegation parent is the extension class loader for installed
// * extensions).
// */
// private static void loadAssistiveTechnologies() {
// // Load any assistive technologies
// if (atNames != null) {
// ClassLoader cl = ClassLoader.getSystemClassLoader();
// StringTokenizer parser = new StringTokenizer(atNames," ,");
// String atName;
// while (parser.hasMoreTokens()) {
// atName = parser.nextToken();
// try {
// Class clazz;
// if (cl != null) {
// clazz = cl.loadClass(atName);
// } else {
// clazz = Class.forName(atName);
// }
// clazz.newInstance();
// } catch (ClassNotFoundException e) {
// throw new AWTError("Assistive Technology not found: "
// + atName);
// } catch (InstantiationException e) {
// throw new AWTError("Could not instantiate Assistive"
// + " Technology: " + atName);
// } catch (IllegalAccessException e) {
// throw new AWTError("Could not access Assistive"
// + " Technology: " + atName);
// } catch (Exception e) {
// throw new AWTError("Error trying to install Assistive"
// + " Technology: " + atName + " " + e);
// }
// }
// }
// }
/**
* Gets the default toolkit.
* <p>
* If a system property named <code>"java.awt.headless"</code> is set
* to <code>true</code> then the headless implementation
* of <code>Toolkit</code> is used.
* <p>
* If there is no <code>"java.awt.headless"</code> or it is set to
* <code>false</code> and there is a system property named
* <code>"awt.toolkit"</code>,
* that property is treated as the name of a class that is a subclass
* of <code>Toolkit</code>;
* otherwise the default platform-specific implementation of
* <code>Toolkit</code> is used.
* <p>
* Also loads additional classes into the VM, using the property
* 'assistive_technologies' specified in the Sun reference
* implementation by a line in the 'accessibility.properties'
* file. The form is "assistive_technologies=..." where
* the "..." is a comma-separated list of assistive technology
* classes to load. Each class is loaded in the order given
* and a single instance of each is created using
* Class.forName(class).newInstance(). This is done just after
* the AWT toolkit is created. All errors are handled via an
* AWTError exception.
* @return the default toolkit.
* @exception AWTError if a toolkit could not be found, or
* if one could not be accessed or instantiated.
*/
public static synchronized Toolkit getDefaultToolkit() {
return (toolkit == null ? toolkit = new JSToolkit() : toolkit);
// //try {
// // We disable the JIT during toolkit initialization. This
// // tends to touch lots of classes that aren't needed again
// // later and therefore JITing is counter-productiive.
//// java.lang.Compiler.disable();
//
//// jsjava.security.AccessController.doPrivileged(
//// new jsjava.security.PrivilegedAction() {
//// public Object run() {
// String nm = null;
// Class cls = null;
// try {
// {
// nm = System.getProperty("awt.toolkit",
// "sun.awt.X11.XToolkit");
// }
// try {
// cls = Class.forName(nm);
// } catch (ClassNotFoundException e) {
// ClassLoader cl = ClassLoader.getSystemClassLoader();
// if (cl != null) {
// try {
// cls = cl.loadClass(nm);
// } catch (ClassNotFoundException ee) {
// throw new AWTError("Toolkit not found: " + nm);
// }
// }
// }
// if (cls != null) {
// toolkit = (Toolkit) cls.newInstance();
// // if (GraphicsEnvironment.isHeadless()) {
// // toolkit = new HeadlessToolkit(toolkit);
// // }
// }
// } catch (InstantiationException e) {
// throw new AWTError("Could not instantiate Toolkit: " + nm);
// } catch (IllegalAccessException e) {
// throw new AWTError("Could not access Toolkit: " + nm);
// }
// return null;
// }
// });
//// loadAssistiveTechnologies();
// } finally {
// // Make sure to always re-enable the JIT.
//// java.lang.Compiler.enable();
// }
// }
// return toolkit;
}
/**
* Returns an image which gets pixel data from the specified file,
* whose format can be either GIF, JPEG or PNG.
* The underlying toolkit attempts to resolve multiple requests
* with the same filename to the same returned Image.
* <p>
* Since the mechanism required to facilitate this sharing of
* <code>Image</code> objects may continue to hold onto images
* that are no longer in use for an indefinite period of time,
* developers are encouraged to implement their own caching of
* images by using the {@link #createImage(java.lang.String) createImage}
* variant wherever available.
* If the image data contained in the specified file changes,
* the <code>Image</code> object returned from this method may
* still contain stale information which was loaded from the
* file after a prior call.
* Previously loaded image data can be manually discarded by
* calling the {@link Image#flush flush} method on the
* returned <code>Image</code>.
* <p>
* This method first checks if there is a security manager installed.
* If so, the method calls the security manager's
* <code>checkRead</code> method with the file specified to ensure
* that the access to the image is allowed.
* @param filename the name of a file containing pixel data
* in a recognized file format.
* @return an image which gets its pixel data from
* the specified file.
* @throws SecurityException if a security manager exists and its
* checkRead method doesn't allow the operation.
* @see #createImage(java.lang.String)
*/
public abstract Image getImage(String filename);
/**
* Returns an image which gets pixel data from the specified URL.
* The pixel data referenced by the specified URL must be in one
* of the following formats: GIF, JPEG or PNG.
* The underlying toolkit attempts to resolve multiple requests
* with the same URL to the same returned Image.
* <p>
* Since the mechanism required to facilitate this sharing of
* <code>Image</code> objects may continue to hold onto images
* that are no longer in use for an indefinite period of time,
* developers are encouraged to implement their own caching of
* images by using the {@link #createImage(java.net.URL) createImage}
* variant wherever available.
* If the image data stored at the specified URL changes,
* the <code>Image</code> object returned from this method may
* still contain stale information which was fetched from the
* URL after a prior call.
* Previously loaded image data can be manually discarded by
* calling the {@link Image#flush flush} method on the
* returned <code>Image</code>.
* <p>
* This method first checks if there is a security manager installed.
* If so, the method calls the security manager's
* <code>checkPermission</code> method with the
* url.openConnection().getPermission() permission to ensure
* that the access to the image is allowed. For compatibility
* with pre-1.2 security managers, if the access is denied with
* <code>FilePermission</code> or <code>SocketPermission</code>,
* the method throws the <code>SecurityException</code>
* if the corresponding 1.1-style SecurityManager.checkXXX method
* also denies permission.
* @param url the URL to use in fetching the pixel data.
* @return an image which gets its pixel data from
* the specified URL.
* @throws SecurityException if a security manager exists and its
* checkPermission method doesn't allow
* the operation.
* @see #createImage(java.net.URL)
*/
public abstract Image getImage(URL url);
/**
* Returns an image which gets pixel data from the specified file.
* The returned Image is a new object which will not be shared
* with any other caller of this method or its getImage variant.
* <p>
* This method first checks if there is a security manager installed.
* If so, the method calls the security manager's
* <code>checkRead</code> method with the specified file to ensure
* that the image creation is allowed.
* @param filename the name of a file containing pixel data
* in a recognized file format.
* @return an image which gets its pixel data from
* the specified file.
* @throws SecurityException if a security manager exists and its
* checkRead method doesn't allow the operation.
* @see #getImage(java.lang.String)
*/
public abstract Image createImage(String filename);
/**
* Returns an image which gets pixel data from the specified URL.
* The returned Image is a new object which will not be shared
* with any other caller of this method or its getImage variant.
* <p>
* This method first checks if there is a security manager installed.