3a7cbc8d59270fd196a82bbb791f2aeec9c4e017
[jalviewjs.git] / site / swingjs / j2s / javax / swing / AbstractButton.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.awt.ItemSelectable", "java.awt.event.ActionListener", "$.ItemListener", "javax.swing.ActionPropertyChangeListener", "$.JComponent", "$.SwingConstants", "javax.swing.event.ChangeListener"], "javax.swing.AbstractButton", ["java.lang.Boolean", "$.IllegalArgumentException", "java.awt.event.ActionEvent", "$.ItemEvent", "javax.swing.AbstractAction", "$.DefaultButtonModel", "$.OverlayLayout", "$.SwingUtilities", "$.UIManager", "javax.swing.event.ChangeEvent", "javax.swing.plaf.UIResource"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.model = null;
5 this.text = "";
6 this.margin = null;
7 this.defaultMargin = null;
8 this.defaultIcon = null;
9 this.pressedIcon = null;
10 this.disabledIcon = null;
11 this.selectedIcon = null;
12 this.disabledSelectedIcon = null;
13 this.rolloverIcon = null;
14 this.rolloverSelectedIcon = null;
15 this.$paintBorder = true;
16 this.paintFocus = true;
17 this.rolloverEnabled = false;
18 this.contentAreaFilled = true;
19 this.verticalAlignment = 0;
20 this.horizontalAlignment = 0;
21 this.verticalTextPosition = 0;
22 this.horizontalTextPosition = 11;
23 this.iconTextGap = 4;
24 this.mnemonic = 0;
25 this.mnemonicIndex = -1;
26 this.multiClickThreshhold = 0;
27 this.borderPaintedSet = false;
28 this.rolloverEnabledSet = false;
29 this.iconTextGapSet = false;
30 this.contentAreaFilledSet = false;
31 this.$setLayout = false;
32 this.defaultCapable = true;
33 this.handler = null;
34 this.changeListener = null;
35 this.actionListener = null;
36 this.itemListener = null;
37 this.changeEvent = null;
38 this.hideActionText = false;
39 this.$action = null;
40 this.actionPropertyChangeListener = null;
41 if (!Clazz.isClassDefined ("javax.swing.AbstractButton.ButtonChangeListener")) {
42 javax.swing.AbstractButton.$AbstractButton$ButtonChangeListener$ ();
43 }
44 if (!Clazz.isClassDefined ("javax.swing.AbstractButton.Handler")) {
45 javax.swing.AbstractButton.$AbstractButton$Handler$ ();
46 }
47 Clazz.instantialize (this, arguments);
48 }, javax.swing, "AbstractButton", javax.swing.JComponent, [java.awt.ItemSelectable, javax.swing.SwingConstants]);
49 Clazz.defineMethod (c$, "setHideActionText", 
50 function (hideActionText) {
51 if (hideActionText != this.hideActionText) {
52 this.hideActionText = hideActionText;
53 if (this.getAction () != null) {
54 this.setTextFromAction (this.getAction (), false);
55 }this.firePropertyChangeBool ("hideActionText", !hideActionText, hideActionText);
56 }}, "~B");
57 Clazz.defineMethod (c$, "getHideActionText", 
58 function () {
59 return this.hideActionText;
60 });
61 Clazz.defineMethod (c$, "getText", 
62 function () {
63 return this.text;
64 });
65 Clazz.defineMethod (c$, "setText", 
66 function (text) {
67 var oldValue = this.text;
68 this.text = text;
69 this.firePropertyChangeObject ("text", oldValue, text);
70 this.updateDisplayedMnemonicIndex (text, this.getMnemonic ());
71 if (text == null || oldValue == null || !text.equals (oldValue)) {
72 this.revalidate ();
73 this.repaint ();
74 }}, "~S");
75 Clazz.defineMethod (c$, "isSelected", 
76 function () {
77 return this.model.isSelected ();
78 });
79 Clazz.defineMethod (c$, "setSelected", 
80 function (b) {
81 this.model.setSelected (b);
82 }, "~B");
83 Clazz.defineMethod (c$, "doClick", 
84 function () {
85 this.doClick (68);
86 });
87 Clazz.defineMethod (c$, "doClick", 
88 function (pressTime) {
89 }, "~N");
90 Clazz.defineMethod (c$, "setMargin", 
91 function (m) {
92 if (Clazz.instanceOf (m, javax.swing.plaf.UIResource)) {
93 this.defaultMargin = m;
94 } else if (Clazz.instanceOf (this.margin, javax.swing.plaf.UIResource)) {
95 this.defaultMargin = this.margin;
96 }if (m == null && this.defaultMargin != null) {
97 m = this.defaultMargin;
98 }var old = this.margin;
99 this.margin = m;
100 this.firePropertyChangeObject ("margin", old, m);
101 if (old == null || !old.equals (m)) {
102 this.revalidate ();
103 this.repaint ();
104 }}, "java.awt.Insets");
105 Clazz.defineMethod (c$, "getMargin", 
106 function () {
107 return (this.margin == null) ? null : this.margin.clone ();
108 });
109 Clazz.defineMethod (c$, "getIcon", 
110 function () {
111 return this.defaultIcon;
112 });
113 Clazz.defineMethod (c$, "setIcon", 
114 function (defaultIcon) {
115 var oldValue = this.defaultIcon;
116 this.defaultIcon = defaultIcon;
117 if (defaultIcon !== oldValue && (Clazz.instanceOf (this.disabledIcon, javax.swing.plaf.UIResource))) {
118 this.disabledIcon = null;
119 }this.firePropertyChangeObject ("icon", oldValue, defaultIcon);
120 if (defaultIcon !== oldValue) {
121 if (defaultIcon == null || oldValue == null || defaultIcon.getIconWidth () != oldValue.getIconWidth () || defaultIcon.getIconHeight () != oldValue.getIconHeight ()) {
122 this.revalidate ();
123 }this.repaint ();
124 }}, "javax.swing.Icon");
125 Clazz.defineMethod (c$, "getPressedIcon", 
126 function () {
127 return this.pressedIcon;
128 });
129 Clazz.defineMethod (c$, "setPressedIcon", 
130 function (pressedIcon) {
131 var oldValue = this.pressedIcon;
132 this.pressedIcon = pressedIcon;
133 this.firePropertyChangeObject ("pressedIcon", oldValue, pressedIcon);
134 if (pressedIcon !== oldValue) {
135 if (this.getModel ().isPressed ()) {
136 this.repaint ();
137 }}}, "javax.swing.Icon");
138 Clazz.defineMethod (c$, "getSelectedIcon", 
139 function () {
140 return this.selectedIcon;
141 });
142 Clazz.defineMethod (c$, "setSelectedIcon", 
143 function (selectedIcon) {
144 var oldValue = this.selectedIcon;
145 this.selectedIcon = selectedIcon;
146 if (selectedIcon !== oldValue && Clazz.instanceOf (this.disabledSelectedIcon, javax.swing.plaf.UIResource)) {
147 this.disabledSelectedIcon = null;
148 }this.firePropertyChangeObject ("selectedIcon", oldValue, selectedIcon);
149 if (selectedIcon !== oldValue) {
150 if (this.isSelected ()) {
151 this.repaint ();
152 }}}, "javax.swing.Icon");
153 Clazz.defineMethod (c$, "getRolloverIcon", 
154 function () {
155 return this.rolloverIcon;
156 });
157 Clazz.defineMethod (c$, "setRolloverIcon", 
158 function (rolloverIcon) {
159 var oldValue = this.rolloverIcon;
160 this.rolloverIcon = rolloverIcon;
161 this.firePropertyChangeObject ("rolloverIcon", oldValue, rolloverIcon);
162 this.setRolloverEnabled (true);
163 if (rolloverIcon !== oldValue) {
164 this.repaint ();
165 }}, "javax.swing.Icon");
166 Clazz.defineMethod (c$, "getRolloverSelectedIcon", 
167 function () {
168 return this.rolloverSelectedIcon;
169 });
170 Clazz.defineMethod (c$, "setRolloverSelectedIcon", 
171 function (rolloverSelectedIcon) {
172 var oldValue = this.rolloverSelectedIcon;
173 this.rolloverSelectedIcon = rolloverSelectedIcon;
174 this.firePropertyChangeObject ("rolloverSelectedIcon", oldValue, rolloverSelectedIcon);
175 this.setRolloverEnabled (true);
176 if (rolloverSelectedIcon !== oldValue) {
177 if (this.isSelected ()) {
178 this.repaint ();
179 }}}, "javax.swing.Icon");
180 Clazz.defineMethod (c$, "getDisabledIcon", 
181 function () {
182 if (this.disabledIcon == null) {
183 this.disabledIcon = javax.swing.UIManager.getLookAndFeel ().getDisabledIcon (this, this.getIcon ());
184 if (this.disabledIcon != null) {
185 this.firePropertyChangeObject ("disabledIcon", null, this.disabledIcon);
186 }}return this.disabledIcon;
187 });
188 Clazz.defineMethod (c$, "setDisabledIcon", 
189 function (disabledIcon) {
190 var oldValue = this.disabledIcon;
191 this.disabledIcon = disabledIcon;
192 this.firePropertyChangeObject ("disabledIcon", oldValue, disabledIcon);
193 if (disabledIcon !== oldValue) {
194 if (!this.isEnabled ()) {
195 this.repaint ();
196 }}}, "javax.swing.Icon");
197 Clazz.defineMethod (c$, "getDisabledSelectedIcon", 
198 function () {
199 if (this.disabledSelectedIcon == null) {
200 if (this.selectedIcon != null) {
201 this.disabledSelectedIcon = javax.swing.UIManager.getLookAndFeel ().getDisabledSelectedIcon (this, this.getSelectedIcon ());
202 } else {
203 return this.getDisabledIcon ();
204 }}return this.disabledSelectedIcon;
205 });
206 Clazz.defineMethod (c$, "setDisabledSelectedIcon", 
207 function (disabledSelectedIcon) {
208 var oldValue = this.disabledSelectedIcon;
209 this.disabledSelectedIcon = disabledSelectedIcon;
210 this.firePropertyChangeObject ("disabledSelectedIcon", oldValue, disabledSelectedIcon);
211 if (disabledSelectedIcon !== oldValue) {
212 if (disabledSelectedIcon == null || oldValue == null || disabledSelectedIcon.getIconWidth () != oldValue.getIconWidth () || disabledSelectedIcon.getIconHeight () != oldValue.getIconHeight ()) {
213 this.revalidate ();
214 }if (!this.isEnabled () && this.isSelected ()) {
215 this.repaint ();
216 }}}, "javax.swing.Icon");
217 Clazz.defineMethod (c$, "getVerticalAlignment", 
218 function () {
219 return this.verticalAlignment;
220 });
221 Clazz.defineMethod (c$, "setVerticalAlignment", 
222 function (alignment) {
223 if (alignment == this.verticalAlignment) return;
224 var oldValue = this.verticalAlignment;
225 this.verticalAlignment = this.checkVerticalKey (alignment, "verticalAlignment");
226 this.firePropertyChangeInt ("verticalAlignment", oldValue, this.verticalAlignment);
227 this.repaint ();
228 }, "~N");
229 Clazz.defineMethod (c$, "getHorizontalAlignment", 
230 function () {
231 return this.horizontalAlignment;
232 });
233 Clazz.defineMethod (c$, "setHorizontalAlignment", 
234 function (alignment) {
235 if (alignment == this.horizontalAlignment) return;
236 var oldValue = this.horizontalAlignment;
237 this.horizontalAlignment = this.checkHorizontalKey (alignment, "horizontalAlignment");
238 this.firePropertyChangeInt ("horizontalAlignment", oldValue, this.horizontalAlignment);
239 this.repaint ();
240 }, "~N");
241 Clazz.defineMethod (c$, "getVerticalTextPosition", 
242 function () {
243 return this.verticalTextPosition;
244 });
245 Clazz.defineMethod (c$, "setVerticalTextPosition", 
246 function (textPosition) {
247 if (textPosition == this.verticalTextPosition) return;
248 var oldValue = this.verticalTextPosition;
249 this.verticalTextPosition = this.checkVerticalKey (textPosition, "verticalTextPosition");
250 this.firePropertyChangeInt ("verticalTextPosition", oldValue, this.verticalTextPosition);
251 this.revalidate ();
252 this.repaint ();
253 }, "~N");
254 Clazz.defineMethod (c$, "getHorizontalTextPosition", 
255 function () {
256 return this.horizontalTextPosition;
257 });
258 Clazz.defineMethod (c$, "setHorizontalTextPosition", 
259 function (textPosition) {
260 if (textPosition == this.horizontalTextPosition) return;
261 var oldValue = this.horizontalTextPosition;
262 this.horizontalTextPosition = this.checkHorizontalKey (textPosition, "horizontalTextPosition");
263 this.firePropertyChangeInt ("horizontalTextPosition", oldValue, this.horizontalTextPosition);
264 this.revalidate ();
265 this.repaint ();
266 }, "~N");
267 Clazz.defineMethod (c$, "getIconTextGap", 
268 function () {
269 return this.iconTextGap;
270 });
271 Clazz.defineMethod (c$, "setIconTextGap", 
272 function (iconTextGap) {
273 var oldValue = this.iconTextGap;
274 this.iconTextGap = iconTextGap;
275 this.iconTextGapSet = true;
276 this.firePropertyChangeInt ("iconTextGap", oldValue, iconTextGap);
277 if (iconTextGap != oldValue) {
278 this.revalidate ();
279 this.repaint ();
280 }}, "~N");
281 Clazz.defineMethod (c$, "checkHorizontalKey", 
282 function (key, exception) {
283 if ((key == 2) || (key == 0) || (key == 4) || (key == 10) || (key == 11)) {
284 return key;
285 } else {
286 throw  new IllegalArgumentException (exception);
287 }}, "~N,~S");
288 Clazz.defineMethod (c$, "checkVerticalKey", 
289 function (key, exception) {
290 if ((key == 1) || (key == 0) || (key == 3)) {
291 return key;
292 } else {
293 throw  new IllegalArgumentException (exception);
294 }}, "~N,~S");
295 Clazz.defineMethod (c$, "removeNotify", 
296 function () {
297 Clazz.superCall (this, javax.swing.AbstractButton, "removeNotify", []);
298 if (this.isRolloverEnabled ()) {
299 this.getModel ().setRollover (false);
300 }});
301 Clazz.defineMethod (c$, "setActionCommand", 
302 function (actionCommand) {
303 this.getModel ().setActionCommand (actionCommand);
304 }, "~S");
305 Clazz.defineMethod (c$, "getActionCommand", 
306 function () {
307 var ac = this.getModel ().getActionCommand ();
308 if (ac == null) {
309 ac = this.getText ();
310 }return ac;
311 });
312 Clazz.defineMethod (c$, "setAction", 
313 function (a) {
314 var oldValue = this.getAction ();
315 if (this.$action == null || !this.$action.equals (a)) {
316 this.$action = a;
317 if (oldValue != null) {
318 this.removeActionListener (oldValue);
319 oldValue.removePropertyChangeListener (this.actionPropertyChangeListener);
320 this.actionPropertyChangeListener = null;
321 }this.configurePropertiesFromAction (this.$action);
322 if (this.$action != null) {
323 if (!this.isListener (java.awt.event.ActionListener, this.$action)) {
324 this.addActionListener (this.$action);
325 }this.actionPropertyChangeListener = this.createActionPropertyChangeListener (this.$action);
326 this.$action.addPropertyChangeListener (this.actionPropertyChangeListener);
327 }this.firePropertyChangeObject ("action", oldValue, this.$action);
328 }}, "javax.swing.Action");
329 Clazz.defineMethod (c$, "isListener", 
330  function (c, a) {
331 var isListener = false;
332 var listeners = this.listenerList.getListenerList ();
333 for (var i = listeners.length - 2; i >= 0; i -= 2) {
334 if (listeners[i] === c && listeners[i + 1] === a) {
335 isListener = true;
336 }}
337 return isListener;
338 }, "Class,java.awt.event.ActionListener");
339 Clazz.defineMethod (c$, "getAction", 
340 function () {
341 return this.$action;
342 });
343 Clazz.defineMethod (c$, "configurePropertiesFromAction", 
344 function (a) {
345 this.setMnemonicFromAction (a);
346 this.setTextFromAction (a, false);
347 javax.swing.AbstractAction.setToolTipTextFromAction (this, a);
348 this.setIconFromAction (a);
349 this.setActionCommandFromAction (a);
350 javax.swing.AbstractAction.setEnabledFromAction (this, a);
351 if (javax.swing.AbstractAction.hasSelectedKey (a) && this.shouldUpdateSelectedStateFromAction ()) {
352 this.setSelectedFromAction (a);
353 }this.setDisplayedMnemonicIndexFromAction (a, false);
354 }, "javax.swing.Action");
355 Clazz.overrideMethod (c$, "clientPropertyChanged", 
356 function (key, oldValue, newValue) {
357 if (key === "hideActionText") {
358 var current = (Clazz.instanceOf (newValue, Boolean)) ? newValue : false;
359 if (this.getHideActionText () != current) {
360 this.setHideActionText (current);
361 }}}, "~O,~O,~O");
362 Clazz.defineMethod (c$, "shouldUpdateSelectedStateFromAction", 
363 function () {
364 return false;
365 });
366 Clazz.defineMethod (c$, "actionPropertyChanged", 
367 function (action, propertyName) {
368 if (propertyName === "Name") {
369 this.setTextFromAction (action, true);
370 } else if (propertyName === "enabled") {
371 javax.swing.AbstractAction.setEnabledFromAction (this, action);
372 } else if (propertyName === "ShortDescription") {
373 javax.swing.AbstractAction.setToolTipTextFromAction (this, action);
374 } else if (propertyName === "SmallIcon") {
375 this.smallIconChanged (action);
376 } else if (propertyName === "MnemonicKey") {
377 this.setMnemonicFromAction (action);
378 } else if (propertyName === "ActionCommandKey") {
379 this.setActionCommandFromAction (action);
380 } else if (propertyName === "SwingSelectedKey" && javax.swing.AbstractAction.hasSelectedKey (action) && this.shouldUpdateSelectedStateFromAction ()) {
381 this.setSelectedFromAction (action);
382 } else if (propertyName === "SwingDisplayedMnemonicIndexKey") {
383 this.setDisplayedMnemonicIndexFromAction (action, true);
384 } else if (propertyName === "SwingLargeIconKey") {
385 this.largeIconChanged (action);
386 }}, "javax.swing.Action,~S");
387 Clazz.defineMethod (c$, "setDisplayedMnemonicIndexFromAction", 
388  function (a, fromPropertyChange) {
389 var iValue = (a == null) ? null : a.getValue ("SwingDisplayedMnemonicIndexKey");
390 if (fromPropertyChange || iValue != null) {
391 var value;
392 if (iValue == null) {
393 value = -1;
394 } else {
395 value = (iValue).intValue ();
396 var text = this.getText ();
397 if (text == null || value >= text.length) {
398 value = -1;
399 }}this.setDisplayedMnemonicIndex (value);
400 }}, "javax.swing.Action,~B");
401 Clazz.defineMethod (c$, "setMnemonicFromAction", 
402  function (a) {
403 var n = (a == null) ? null : a.getValue ("MnemonicKey");
404 this.setMnemonic ((n == null) ? '\0' : n);
405 }, "javax.swing.Action");
406 Clazz.defineMethod (c$, "setTextFromAction", 
407  function (a, propertyChange) {
408 var hideText = this.getHideActionText ();
409 if (!propertyChange) {
410 this.setText ((a != null && !hideText) ? a.getValue ("Name") : null);
411 } else if (!hideText) {
412 this.setText (a.getValue ("Name"));
413 }}, "javax.swing.Action,~B");
414 Clazz.defineMethod (c$, "setIconFromAction", 
415 function (a) {
416 var icon = null;
417 if (a != null) {
418 icon = a.getValue ("SwingLargeIconKey");
419 if (icon == null) {
420 icon = a.getValue ("SmallIcon");
421 }}this.setIcon (icon);
422 }, "javax.swing.Action");
423 Clazz.defineMethod (c$, "smallIconChanged", 
424 function (a) {
425 if (a.getValue ("SwingLargeIconKey") == null) {
426 this.setIconFromAction (a);
427 }}, "javax.swing.Action");
428 Clazz.defineMethod (c$, "largeIconChanged", 
429 function (a) {
430 this.setIconFromAction (a);
431 }, "javax.swing.Action");
432 Clazz.defineMethod (c$, "setActionCommandFromAction", 
433  function (a) {
434 this.setActionCommand ((a != null) ? a.getValue ("ActionCommandKey") : null);
435 }, "javax.swing.Action");
436 Clazz.defineMethod (c$, "setSelectedFromAction", 
437  function (a) {
438 var selected = false;
439 if (a != null) {
440 selected = javax.swing.AbstractAction.isSelected (a);
441 }if (selected != this.isSelected ()) {
442 this.setSelected (selected);
443 if (!selected && this.isSelected ()) {
444 if (Clazz.instanceOf (this.getModel (), javax.swing.DefaultButtonModel)) {
445 var group = (this.getModel ()).getGroup ();
446 if (group != null) {
447 group.clearSelection ();
448 }}}}}, "javax.swing.Action");
449 Clazz.defineMethod (c$, "createActionPropertyChangeListener", 
450 function (a) {
451 return this.createActionPropertyChangeListener0 (a);
452 }, "javax.swing.Action");
453 Clazz.defineMethod (c$, "createActionPropertyChangeListener0", 
454 function (a) {
455 return  new javax.swing.AbstractButton.ButtonActionPropertyChangeListener (this, a);
456 }, "javax.swing.Action");
457 Clazz.defineMethod (c$, "isBorderPainted", 
458 function () {
459 return this.$paintBorder;
460 });
461 Clazz.defineMethod (c$, "setBorderPainted", 
462 function (b) {
463 var oldValue = this.$paintBorder;
464 this.$paintBorder = b;
465 this.borderPaintedSet = true;
466 this.firePropertyChangeBool ("borderPainted", oldValue, this.$paintBorder);
467 if (b != oldValue) {
468 this.revalidate ();
469 this.repaint ();
470 }}, "~B");
471 Clazz.defineMethod (c$, "paintBorder", 
472 function (g) {
473 if (this.isBorderPainted ()) {
474 Clazz.superCall (this, javax.swing.AbstractButton, "paintBorder", [g]);
475 }}, "java.awt.Graphics");
476 Clazz.defineMethod (c$, "isFocusPainted", 
477 function () {
478 return this.paintFocus;
479 });
480 Clazz.defineMethod (c$, "setFocusPainted", 
481 function (b) {
482 var oldValue = this.paintFocus;
483 this.paintFocus = b;
484 this.firePropertyChangeBool ("focusPainted", oldValue, this.paintFocus);
485 if (b != oldValue && this.isFocusOwner ()) {
486 this.revalidate ();
487 this.repaint ();
488 }}, "~B");
489 Clazz.defineMethod (c$, "isContentAreaFilled", 
490 function () {
491 return this.contentAreaFilled;
492 });
493 Clazz.defineMethod (c$, "setContentAreaFilled", 
494 function (b) {
495 var oldValue = this.contentAreaFilled;
496 this.contentAreaFilled = b;
497 this.contentAreaFilledSet = true;
498 this.firePropertyChangeBool ("contentAreaFilled", oldValue, this.contentAreaFilled);
499 if (b != oldValue) {
500 this.repaint ();
501 }}, "~B");
502 Clazz.defineMethod (c$, "isRolloverEnabled", 
503 function () {
504 return this.rolloverEnabled;
505 });
506 Clazz.defineMethod (c$, "setRolloverEnabled", 
507 function (b) {
508 var oldValue = this.rolloverEnabled;
509 this.rolloverEnabled = b;
510 this.rolloverEnabledSet = true;
511 this.firePropertyChangeBool ("rolloverEnabled", oldValue, this.rolloverEnabled);
512 if (b != oldValue) {
513 this.repaint ();
514 }}, "~B");
515 Clazz.defineMethod (c$, "getMnemonic", 
516 function () {
517 return this.mnemonic;
518 });
519 Clazz.defineMethod (c$, "setMnemonic", 
520 function (mnemonic) {
521 this.model.setMnemonic (mnemonic);
522 this.updateMnemonicProperties ();
523 }, "~N");
524 Clazz.defineMethod (c$, "setMnemonic", 
525 function (mnemonic) {
526 var vk = (mnemonic).charCodeAt (0);
527 if (vk >= 97 && vk <= 122) vk -= (32);
528 this.setMnemonic (vk);
529 }, "~S");
530 Clazz.defineMethod (c$, "setDisplayedMnemonicIndex", 
531 function (index) {
532 var oldValue = this.mnemonicIndex;
533 if (index == -1) {
534 this.mnemonicIndex = -1;
535 } else {
536 var text = this.getText ();
537 var textLength = (text == null) ? 0 : text.length;
538 if (index < -1 || index >= textLength) {
539 throw  new IllegalArgumentException ("index == " + index);
540 }}this.mnemonicIndex = index;
541 this.firePropertyChangeInt ("displayedMnemonicIndex", oldValue, index);
542 if (index != oldValue) {
543 this.revalidate ();
544 this.repaint ();
545 }}, "~N");
546 Clazz.defineMethod (c$, "getDisplayedMnemonicIndex", 
547 function () {
548 return this.mnemonicIndex;
549 });
550 Clazz.defineMethod (c$, "updateDisplayedMnemonicIndex", 
551  function (text, mnemonic) {
552 this.setDisplayedMnemonicIndex (javax.swing.SwingUtilities.findDisplayedMnemonicIndex (text, mnemonic));
553 }, "~S,~N");
554 Clazz.defineMethod (c$, "updateMnemonicProperties", 
555  function () {
556 var newMnemonic = this.model.getMnemonic ();
557 if (this.mnemonic != newMnemonic) {
558 var oldValue = this.mnemonic;
559 this.mnemonic = newMnemonic;
560 this.firePropertyChangeInt ("mnemonic", oldValue, this.mnemonic);
561 this.updateDisplayedMnemonicIndex (this.getText (), this.mnemonic);
562 this.revalidate ();
563 this.repaint ();
564 }});
565 Clazz.defineMethod (c$, "setMultiClickThreshhold", 
566 function (threshhold) {
567 if (threshhold < 0) {
568 throw  new IllegalArgumentException ("threshhold must be >= 0");
569 }this.multiClickThreshhold = threshhold;
570 }, "~N");
571 Clazz.defineMethod (c$, "getMultiClickThreshhold", 
572 function () {
573 return this.multiClickThreshhold;
574 });
575 Clazz.defineMethod (c$, "getModel", 
576 function () {
577 return this.model;
578 });
579 Clazz.defineMethod (c$, "setModel", 
580 function (newModel) {
581 var oldModel = this.getModel ();
582 if (oldModel != null) {
583 oldModel.removeChangeListener (this.changeListener);
584 oldModel.removeActionListener (this.actionListener);
585 oldModel.removeItemListener (this.itemListener);
586 this.changeListener = null;
587 this.actionListener = null;
588 this.itemListener = null;
589 }this.model = newModel;
590 if (newModel != null) {
591 this.changeListener = this.createChangeListener ();
592 this.actionListener = this.createActionListener ();
593 this.itemListener = this.createItemListener ();
594 newModel.addChangeListener (this.changeListener);
595 newModel.addActionListener (this.actionListener);
596 newModel.addItemListener (this.itemListener);
597 this.updateMnemonicProperties ();
598 Clazz.superCall (this, javax.swing.AbstractButton, "setEnabled", [newModel.isEnabled ()]);
599 } else {
600 this.mnemonic = 0;
601 }this.updateDisplayedMnemonicIndex (this.getText (), this.mnemonic);
602 this.firePropertyChangeObject ("model", oldModel, newModel);
603 if (newModel !== oldModel) {
604 this.revalidate ();
605 this.repaint ();
606 }}, "javax.swing.ButtonModel");
607 Clazz.overrideMethod (c$, "getUI", 
608 function () {
609 return this.ui;
610 });
611 Clazz.defineMethod (c$, "setUI", 
612 function (ui) {
613 Clazz.superCall (this, javax.swing.AbstractButton, "setUI", [ui]);
614 if (Clazz.instanceOf (this.disabledIcon, javax.swing.plaf.UIResource)) {
615 this.setDisabledIcon (null);
616 }if (Clazz.instanceOf (this.disabledSelectedIcon, javax.swing.plaf.UIResource)) {
617 this.setDisabledSelectedIcon (null);
618 }}, "javax.swing.plaf.ButtonUI");
619 Clazz.overrideMethod (c$, "updateUI", 
620 function () {
621 });
622 Clazz.overrideMethod (c$, "addImpl", 
623 function (comp, constraints, index) {
624 if (!this.$setLayout) {
625 this.setLayout ( new javax.swing.OverlayLayout (this));
626 }return this.addImplSAEM (comp, constraints, index);
627 }, "java.awt.Component,~O,~N");
628 Clazz.defineMethod (c$, "setLayout", 
629 function (mgr) {
630 this.$setLayout = true;
631 Clazz.superCall (this, javax.swing.AbstractButton, "setLayout", [mgr]);
632 }, "java.awt.LayoutManager");
633 Clazz.defineMethod (c$, "addChangeListener", 
634 function (l) {
635 this.listenerList.add (javax.swing.event.ChangeListener, l);
636 }, "javax.swing.event.ChangeListener");
637 Clazz.defineMethod (c$, "removeChangeListener", 
638 function (l) {
639 this.listenerList.remove (javax.swing.event.ChangeListener, l);
640 }, "javax.swing.event.ChangeListener");
641 Clazz.defineMethod (c$, "getChangeListeners", 
642 function () {
643 return (this.listenerList.getListeners (javax.swing.event.ChangeListener));
644 });
645 Clazz.defineMethod (c$, "fireStateChanged", 
646 function () {
647 var listeners = this.listenerList.getListenerList ();
648 for (var i = listeners.length - 2; i >= 0; i -= 2) {
649 if (listeners[i] === javax.swing.event.ChangeListener) {
650 if (this.changeEvent == null) this.changeEvent =  new javax.swing.event.ChangeEvent (this);
651 (listeners[i + 1]).stateChanged (this.changeEvent);
652 }}
653 });
654 Clazz.defineMethod (c$, "addActionListener", 
655 function (l) {
656 this.listenerList.add (java.awt.event.ActionListener, l);
657 }, "java.awt.event.ActionListener");
658 Clazz.defineMethod (c$, "removeActionListener", 
659 function (l) {
660 if ((l != null) && (this.getAction () === l)) {
661 this.setAction (null);
662 } else {
663 this.listenerList.remove (java.awt.event.ActionListener, l);
664 }}, "java.awt.event.ActionListener");
665 Clazz.defineMethod (c$, "getActionListeners", 
666 function () {
667 return (this.listenerList.getListeners (java.awt.event.ActionListener));
668 });
669 Clazz.defineMethod (c$, "createChangeListener", 
670 function () {
671 return this.getHandler ();
672 });
673 Clazz.defineMethod (c$, "fireActionPerformed", 
674 function (event) {
675 var listeners = this.listenerList.getListenerList ();
676 var e = null;
677 for (var i = listeners.length - 2; i >= 0; i -= 2) {
678 if (listeners[i] === java.awt.event.ActionListener) {
679 if (e == null) {
680 var actionCommand = event.getActionCommand ();
681 if (actionCommand == null) {
682 actionCommand = this.getActionCommand ();
683 }e =  new java.awt.event.ActionEvent (this, 1001, actionCommand, event.getWhen (), event.getModifiers ());
684 }(listeners[i + 1]).actionPerformed (e);
685 }}
686 }, "java.awt.event.ActionEvent");
687 Clazz.defineMethod (c$, "fireItemStateChanged", 
688 function (event) {
689 var listeners = this.listenerList.getListenerList ();
690 var e = null;
691 for (var i = listeners.length - 2; i >= 0; i -= 2) {
692 if (listeners[i] === java.awt.event.ItemListener) {
693 if (e == null) {
694 e =  new java.awt.event.ItemEvent (this, 701, this, event.getStateChange ());
695 }(listeners[i + 1]).itemStateChanged (e);
696 }}
697 }, "java.awt.event.ItemEvent");
698 Clazz.defineMethod (c$, "createActionListener", 
699 function () {
700 return this.getHandler ();
701 });
702 Clazz.defineMethod (c$, "createItemListener", 
703 function () {
704 return this.getHandler ();
705 });
706 Clazz.defineMethod (c$, "setEnabled", 
707 function (b) {
708 if (!b && this.model.isRollover ()) {
709 this.model.setRollover (false);
710 }Clazz.superCall (this, javax.swing.AbstractButton, "setEnabled", [b]);
711 this.model.setEnabled (b);
712 }, "~B");
713 Clazz.defineMethod (c$, "getLabel", 
714 function () {
715 return this.getText ();
716 });
717 Clazz.defineMethod (c$, "setLabel", 
718 function (label) {
719 this.setText (label);
720 }, "~S");
721 Clazz.overrideMethod (c$, "addItemListener", 
722 function (l) {
723 this.listenerList.add (java.awt.event.ItemListener, l);
724 }, "java.awt.event.ItemListener");
725 Clazz.overrideMethod (c$, "removeItemListener", 
726 function (l) {
727 this.listenerList.remove (java.awt.event.ItemListener, l);
728 }, "java.awt.event.ItemListener");
729 Clazz.defineMethod (c$, "getItemListeners", 
730 function () {
731 return this.listenerList.getListeners (java.awt.event.ItemListener);
732 });
733 Clazz.overrideMethod (c$, "getSelectedObjects", 
734 function () {
735 if (this.isSelected () == false) {
736 return null;
737 }var selectedObjects =  new Array (1);
738 selectedObjects[0] = this.getText ();
739 return selectedObjects;
740 });
741 Clazz.defineMethod (c$, "init", 
742 function (text, icon) {
743 if (text != null) {
744 this.setText (text);
745 }if (icon != null) {
746 this.setIcon (icon);
747 }this.updateUI ();
748 this.setAlignmentX (0.0);
749 this.setAlignmentY (0.5);
750 }, "~S,javax.swing.Icon");
751 Clazz.defineMethod (c$, "imageUpdate", 
752 function (img, infoflags, x, y, w, h) {
753 var iconDisplayed = this.getIcon ();
754 if (iconDisplayed == null) {
755 return false;
756 }if (!this.model.isEnabled ()) {
757 if (this.model.isSelected ()) {
758 iconDisplayed = this.getDisabledSelectedIcon ();
759 } else {
760 iconDisplayed = this.getDisabledIcon ();
761 }} else if (this.model.isPressed () && this.model.isArmed ()) {
762 iconDisplayed = this.getPressedIcon ();
763 } else if (this.isRolloverEnabled () && this.model.isRollover ()) {
764 if (this.model.isSelected ()) {
765 iconDisplayed = this.getRolloverSelectedIcon ();
766 } else {
767 iconDisplayed = this.getRolloverIcon ();
768 }} else if (this.model.isSelected ()) {
769 iconDisplayed = this.getSelectedIcon ();
770 }if (!javax.swing.SwingUtilities.doesIconReferenceImage (iconDisplayed, img)) {
771 return false;
772 }return Clazz.superCall (this, javax.swing.AbstractButton, "imageUpdate", [img, infoflags, x, y, w, h]);
773 }, "java.awt.Image,~N,~N,~N,~N,~N");
774 Clazz.defineMethod (c$, "setUIProperty", 
775 function (propertyName, value) {
776 if (propertyName === "borderPainted") {
777 if (!this.borderPaintedSet) {
778 this.setBorderPainted ((value).booleanValue ());
779 this.borderPaintedSet = false;
780 }} else if (propertyName === "rolloverEnabled") {
781 if (!this.rolloverEnabledSet) {
782 this.setRolloverEnabled ((value).booleanValue ());
783 this.rolloverEnabledSet = false;
784 }} else if (propertyName === "iconTextGap") {
785 if (!this.iconTextGapSet) {
786 this.setIconTextGap ((value).intValue ());
787 this.iconTextGapSet = false;
788 }} else if (propertyName === "contentAreaFilled") {
789 if (!this.contentAreaFilledSet) {
790 this.setContentAreaFilled ((value).booleanValue ());
791 this.contentAreaFilledSet = false;
792 }} else {
793 Clazz.superCall (this, javax.swing.AbstractButton, "setUIProperty", [propertyName, value]);
794 }}, "~S,~O");
795 Clazz.defineMethod (c$, "paramString", 
796 function () {
797 var defaultIconString = ((this.defaultIcon != null) && (this.defaultIcon !== this) ? this.defaultIcon.toString () : "");
798 var pressedIconString = ((this.pressedIcon != null) && (this.pressedIcon !== this) ? this.pressedIcon.toString () : "");
799 var disabledIconString = ((this.disabledIcon != null) && (this.disabledIcon !== this) ? this.disabledIcon.toString () : "");
800 var selectedIconString = ((this.selectedIcon != null) && (this.selectedIcon !== this) ? this.selectedIcon.toString () : "");
801 var disabledSelectedIconString = ((this.disabledSelectedIcon != null) && (this.disabledSelectedIcon !== this) ? this.disabledSelectedIcon.toString () : "");
802 var rolloverIconString = ((this.rolloverIcon != null) && (this.rolloverIcon !== this) ? this.rolloverIcon.toString () : "");
803 var rolloverSelectedIconString = ((this.rolloverSelectedIcon != null) && (this.rolloverSelectedIcon !== this) ? this.rolloverSelectedIcon.toString () : "");
804 var paintBorderString = (this.$paintBorder ? "true" : "false");
805 var paintFocusString = (this.paintFocus ? "true" : "false");
806 var rolloverEnabledString = (this.rolloverEnabled ? "true" : "false");
807 return Clazz.superCall (this, javax.swing.AbstractButton, "paramString", []) + ",defaultIcon=" + defaultIconString + ",disabledIcon=" + disabledIconString + ",disabledSelectedIcon=" + disabledSelectedIconString + ",margin=" + this.margin + ",paintBorder=" + paintBorderString + ",paintFocus=" + paintFocusString + ",pressedIcon=" + pressedIconString + ",rolloverEnabled=" + rolloverEnabledString + ",rolloverIcon=" + rolloverIconString + ",rolloverSelectedIcon=" + rolloverSelectedIconString + ",selectedIcon=" + selectedIconString + ",text=" + this.text;
808 });
809 Clazz.defineMethod (c$, "getHandler", 
810  function () {
811 if (this.handler == null) {
812 this.handler = Clazz.innerTypeInstance (javax.swing.AbstractButton.Handler, this, null);
813 }return this.handler;
814 });
815 c$.$AbstractButton$ButtonChangeListener$ = function () {
816 Clazz.pu$h(self.c$);
817 c$ = Clazz.decorateAsClass (function () {
818 Clazz.prepareCallback (this, arguments);
819 Clazz.instantialize (this, arguments);
820 }, javax.swing.AbstractButton, "ButtonChangeListener", null, javax.swing.event.ChangeListener);
821 Clazz.makeConstructor (c$, 
822 function () {
823 });
824 Clazz.overrideMethod (c$, "stateChanged", 
825 function (a) {
826 this.b$["javax.swing.AbstractButton"].getHandler ().stateChanged (a);
827 }, "javax.swing.event.ChangeEvent");
828 c$ = Clazz.p0p ();
829 };
830 c$.$AbstractButton$Handler$ = function () {
831 Clazz.pu$h(self.c$);
832 c$ = Clazz.decorateAsClass (function () {
833 Clazz.prepareCallback (this, arguments);
834 Clazz.instantialize (this, arguments);
835 }, javax.swing.AbstractButton, "Handler", null, [java.awt.event.ActionListener, javax.swing.event.ChangeListener, java.awt.event.ItemListener]);
836 Clazz.overrideMethod (c$, "stateChanged", 
837 function (a) {
838 this.b$["javax.swing.AbstractButton"].updateMnemonicProperties ();
839 if (this.b$["javax.swing.AbstractButton"].isEnabled () != this.b$["javax.swing.AbstractButton"].model.isEnabled ()) {
840 this.b$["javax.swing.AbstractButton"].setEnabled (this.b$["javax.swing.AbstractButton"].model.isEnabled ());
841 }this.b$["javax.swing.AbstractButton"].fireStateChanged ();
842 this.b$["javax.swing.AbstractButton"].repaint ();
843 }, "javax.swing.event.ChangeEvent");
844 Clazz.overrideMethod (c$, "actionPerformed", 
845 function (a) {
846 this.b$["javax.swing.AbstractButton"].fireActionPerformed (a);
847 }, "java.awt.event.ActionEvent");
848 Clazz.overrideMethod (c$, "itemStateChanged", 
849 function (a) {
850 this.b$["javax.swing.AbstractButton"].fireItemStateChanged (a);
851 if (this.b$["javax.swing.AbstractButton"].shouldUpdateSelectedStateFromAction ()) {
852 var b = this.b$["javax.swing.AbstractButton"].getAction ();
853 if (b != null && javax.swing.AbstractAction.hasSelectedKey (b)) {
854 var c = this.b$["javax.swing.AbstractButton"].isSelected ();
855 var d = javax.swing.AbstractAction.isSelected (b);
856 if (d != c) {
857 b.putValue ("SwingSelectedKey", new Boolean (c));
858 }}}}, "java.awt.event.ItemEvent");
859 c$ = Clazz.p0p ();
860 };
861 Clazz.pu$h(self.c$);
862 c$ = Clazz.declareType (javax.swing.AbstractButton, "ButtonActionPropertyChangeListener", javax.swing.ActionPropertyChangeListener);
863 Clazz.overrideMethod (c$, "actionPropertyChanged", 
864 function (a, b, c) {
865 if (javax.swing.AbstractAction.shouldReconfigure (c)) {
866 a.configurePropertiesFromAction (b);
867 } else {
868 a.actionPropertyChanged (b, c.getPropertyName ());
869 }}, "javax.swing.AbstractButton,javax.swing.Action,java.beans.PropertyChangeEvent");
870 c$ = Clazz.p0p ();
871 Clazz.defineStatics (c$,
872 "MODEL_CHANGED_PROPERTY", "model",
873 "TEXT_CHANGED_PROPERTY", "text",
874 "MNEMONIC_CHANGED_PROPERTY", "mnemonic",
875 "MARGIN_CHANGED_PROPERTY", "margin",
876 "VERTICAL_ALIGNMENT_CHANGED_PROPERTY", "verticalAlignment",
877 "HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY", "horizontalAlignment",
878 "VERTICAL_TEXT_POSITION_CHANGED_PROPERTY", "verticalTextPosition",
879 "HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY", "horizontalTextPosition",
880 "BORDER_PAINTED_CHANGED_PROPERTY", "borderPainted",
881 "FOCUS_PAINTED_CHANGED_PROPERTY", "focusPainted",
882 "ROLLOVER_ENABLED_CHANGED_PROPERTY", "rolloverEnabled",
883 "CONTENT_AREA_FILLED_CHANGED_PROPERTY", "contentAreaFilled",
884 "ICON_CHANGED_PROPERTY", "icon",
885 "PRESSED_ICON_CHANGED_PROPERTY", "pressedIcon",
886 "SELECTED_ICON_CHANGED_PROPERTY", "selectedIcon",
887 "ROLLOVER_ICON_CHANGED_PROPERTY", "rolloverIcon",
888 "ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY", "rolloverSelectedIcon",
889 "DISABLED_ICON_CHANGED_PROPERTY", "disabledIcon",
890 "DISABLED_SELECTED_ICON_CHANGED_PROPERTY", "disabledSelectedIcon");
891 });