JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / Frame.js
1 Clazz.declarePackage ("java.awt");\r
2 Clazz.load (["java.awt.Window"], "java.awt.Frame", ["java.lang.IllegalArgumentException", "java.awt.Cursor", "$.IllegalComponentStateException"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.maximizedBounds = null;\r
5 this.title = "Untitled";\r
6 this.resizable = true;\r
7 this.undecorated = false;\r
8 this.mbManagement = false;\r
9 this.$state = 0;\r
10 this.ownedWindows = null;\r
11 this.menuBar = null;\r
12 Clazz.instantialize (this, arguments);\r
13 }, java.awt, "Frame", java.awt.Window);\r
14 Clazz.makeConstructor (c$, \r
15 function () {\r
16 this.construct ("");\r
17 });\r
18 Clazz.makeConstructor (c$, \r
19 function (gc) {\r
20 this.construct ("", gc);\r
21 }, "java.awt.GraphicsConfiguration");\r
22 Clazz.makeConstructor (c$, \r
23 function (title) {\r
24 Clazz.superConstructor (this, java.awt.Frame, []);\r
25 this.initFrame (title, null);\r
26 }, "~S");\r
27 Clazz.makeConstructor (c$, \r
28 function (title, gc) {\r
29 Clazz.superConstructor (this, java.awt.Frame, [gc]);\r
30 this.initFrame (title, gc);\r
31 }, "~S,java.awt.GraphicsConfiguration");\r
32 Clazz.defineMethod (c$, "initFrame", \r
33  function (title, gc) {\r
34 this.title = title;\r
35 }, "~S,java.awt.GraphicsConfiguration");\r
36 Clazz.overrideMethod (c$, "constructComponentName", \r
37 function () {\r
38 {\r
39 return "frame" + java.awt.Frame.$nameCounter++;\r
40 }});\r
41 Clazz.defineMethod (c$, "addNotify", \r
42 function () {\r
43 if (this.peer == null) {\r
44 this.peer = this.getToolkit ().createFrame (this);\r
45 }var p = this.peer;\r
46 p.setMaximizedBounds (this.maximizedBounds);\r
47 Clazz.superCall (this, java.awt.Frame, "addNotify", []);\r
48 });\r
49 Clazz.defineMethod (c$, "getTitle", \r
50 function () {\r
51 return this.title;\r
52 });\r
53 Clazz.defineMethod (c$, "setTitle", \r
54 function (title) {\r
55 var oldTitle = this.title;\r
56 if (title == null) {\r
57 title = "";\r
58 }{\r
59 this.title = title;\r
60 }this.firePropertyChangeObject ("title", oldTitle, title);\r
61 }, "~S");\r
62 Clazz.defineMethod (c$, "getIconImage", \r
63 function () {\r
64 var icons = this.icons;\r
65 if (icons != null) {\r
66 if (icons.size () > 0) {\r
67 return icons.get (0);\r
68 }}return null;\r
69 });\r
70 Clazz.defineMethod (c$, "isResizable", \r
71 function () {\r
72 return this.resizable;\r
73 });\r
74 Clazz.defineMethod (c$, "setResizable", \r
75 function (resizable) {\r
76 var oldResizable = this.resizable;\r
77 {\r
78 this.resizable = resizable;\r
79 }this.firePropertyChangeBool ("resizable", oldResizable, resizable);\r
80 }, "~B");\r
81 Clazz.defineMethod (c$, "setState", \r
82 function (state) {\r
83 var current = this.getExtendedState ();\r
84 if (state == 1 && (current & 1) == 0) {\r
85 this.setExtendedState (current | 1);\r
86 } else if (state == 0 && (current & 1) != 0) {\r
87 this.setExtendedState (current & -2);\r
88 }}, "~N");\r
89 Clazz.defineMethod (c$, "setExtendedState", \r
90 function (state) {\r
91 if (!this.isFrameStateSupported (state)) {\r
92 return;\r
93 }this.$state = state;\r
94 }, "~N");\r
95 Clazz.defineMethod (c$, "isFrameStateSupported", \r
96  function (state) {\r
97 if (!this.getToolkit ().isFrameStateSupported (state)) {\r
98 if (((state & 1) != 0) && !this.getToolkit ().isFrameStateSupported (1)) {\r
99 return false;\r
100 } else {\r
101 state &= -2;\r
102 }return this.getToolkit ().isFrameStateSupported (state);\r
103 }return true;\r
104 }, "~N");\r
105 Clazz.defineMethod (c$, "getState", \r
106 function () {\r
107 return (this.getExtendedState () & 1) != 0 ? 1 : 0;\r
108 });\r
109 Clazz.defineMethod (c$, "getExtendedState", \r
110 function () {\r
111 return this.$state;\r
112 });\r
113 Clazz.defineMethod (c$, "setMaximizedBounds", \r
114 function (bounds) {\r
115 this.maximizedBounds = bounds;\r
116 }, "java.awt.Rectangle");\r
117 Clazz.defineMethod (c$, "getMaximizedBounds", \r
118 function () {\r
119 return this.maximizedBounds;\r
120 });\r
121 Clazz.defineMethod (c$, "setUndecorated", \r
122 function (undecorated) {\r
123 {\r
124 if (this.isDisplayable ()) {\r
125 throw  new java.awt.IllegalComponentStateException ("The frame is displayable.");\r
126 }this.undecorated = undecorated;\r
127 }}, "~B");\r
128 Clazz.defineMethod (c$, "isUndecorated", \r
129 function () {\r
130 return this.undecorated;\r
131 });\r
132 Clazz.overrideMethod (c$, "removeNotify", \r
133 function () {\r
134 });\r
135 Clazz.defineMethod (c$, "paramString", \r
136 function () {\r
137 var str = Clazz.superCall (this, java.awt.Frame, "paramString", []);\r
138 if (this.title != null) {\r
139 str += ",title=" + this.title;\r
140 }if (this.resizable) {\r
141 str += ",resizable";\r
142 }this.getExtendedState ();\r
143 if (this.$state == 0) {\r
144 str += ",normal";\r
145 } else {\r
146 if ((this.$state & 1) != 0) {\r
147 str += ",iconified";\r
148 }if ((this.$state & 6) == 6) {\r
149 str += ",maximized";\r
150 } else if ((this.$state & 2) != 0) {\r
151 str += ",maximized_horiz";\r
152 } else if ((this.$state & 4) != 0) {\r
153 str += ",maximized_vert";\r
154 }}return str;\r
155 });\r
156 Clazz.defineMethod (c$, "setCursor", \r
157 function (cursorType) {\r
158 if (cursorType < 0 || cursorType > 13) {\r
159 throw  new IllegalArgumentException ("illegal cursor type");\r
160 }this.setCursor (java.awt.Cursor.getPredefinedCursor (cursorType));\r
161 }, "~N");\r
162 Clazz.defineMethod (c$, "getCursorType", \r
163 function () {\r
164 return (this.getCursor ().getType ());\r
165 });\r
166 c$.getFrames = Clazz.defineMethod (c$, "getFrames", \r
167 function () {\r
168 var allWindows = java.awt.Window.getWindows ();\r
169 var frameCount = 0;\r
170 for (var w, $w = 0, $$w = allWindows; $w < $$w.length && ((w = $$w[$w]) || true); $w++) {\r
171 if (Clazz.instanceOf (w, java.awt.Frame)) {\r
172 frameCount++;\r
173 }}\r
174 var frames =  new Array (frameCount);\r
175 var c = 0;\r
176 for (var w, $w = 0, $$w = allWindows; $w < $$w.length && ((w = $$w[$w]) || true); $w++) {\r
177 if (Clazz.instanceOf (w, java.awt.Frame)) {\r
178 frames[c++] = w;\r
179 }}\r
180 return frames;\r
181 });\r
182 Clazz.defineStatics (c$,\r
183 "DEFAULT_CURSOR", 0,\r
184 "CROSSHAIR_CURSOR", 1,\r
185 "TEXT_CURSOR", 2,\r
186 "WAIT_CURSOR", 3,\r
187 "SW_RESIZE_CURSOR", 4,\r
188 "SE_RESIZE_CURSOR", 5,\r
189 "NW_RESIZE_CURSOR", 6,\r
190 "NE_RESIZE_CURSOR", 7,\r
191 "N_RESIZE_CURSOR", 8,\r
192 "S_RESIZE_CURSOR", 9,\r
193 "W_RESIZE_CURSOR", 10,\r
194 "E_RESIZE_CURSOR", 11,\r
195 "HAND_CURSOR", 12,\r
196 "MOVE_CURSOR", 13,\r
197 "NORMAL", 0,\r
198 "ICONIFIED", 1,\r
199 "MAXIMIZED_HORIZ", 2,\r
200 "MAXIMIZED_VERT", 4,\r
201 "MAXIMIZED_BOTH", 6,\r
202 "$base", "frame",\r
203 "$nameCounter", 0);\r
204 });\r