fd1be30122b653cf81ec5ebd3a3848bea6f19c19
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JToggleButton.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.AbstractButton", "$.DefaultButtonModel"], "javax.swing.JToggleButton", ["java.awt.EventQueue", "java.awt.event.ActionEvent", "$.InputEvent", "$.ItemEvent", "javax.swing.UIManager"], function () {
3 c$ = Clazz.declareType (javax.swing, "JToggleButton", javax.swing.AbstractButton);
4 Clazz.makeConstructor (c$, 
5 function () {
6 this.construct (null, null, false);
7 });
8 Clazz.makeConstructor (c$, 
9 function (icon) {
10 this.construct (null, icon, false);
11 }, "javax.swing.Icon");
12 Clazz.makeConstructor (c$, 
13 function (icon, selected) {
14 this.construct (null, icon, selected);
15 }, "javax.swing.Icon,~B");
16 Clazz.makeConstructor (c$, 
17 function (text) {
18 this.construct (text, null, false);
19 }, "~S");
20 Clazz.makeConstructor (c$, 
21 function (text, selected) {
22 this.construct (text, null, selected);
23 }, "~S,~B");
24 Clazz.makeConstructor (c$, 
25 function (a) {
26 this.construct ();
27 this.setAction (a);
28 }, "javax.swing.Action");
29 Clazz.makeConstructor (c$, 
30 function (text, icon) {
31 this.construct (text, icon, false);
32 }, "~S,javax.swing.Icon");
33 Clazz.makeConstructor (c$, 
34 function (text, icon, selected) {
35 Clazz.superConstructor (this, javax.swing.JToggleButton, []);
36 this.setModel ( new javax.swing.JToggleButton.ToggleButtonModel ());
37 this.model.setSelected (selected);
38 this.init (text, icon);
39 }, "~S,javax.swing.Icon,~B");
40 Clazz.overrideMethod (c$, "updateUI", 
41 function () {
42 this.setUI (javax.swing.UIManager.getUI (this));
43 });
44 Clazz.overrideMethod (c$, "getUIClassID", 
45 function () {
46 return "ToggleButtonUI";
47 });
48 Clazz.overrideMethod (c$, "shouldUpdateSelectedStateFromAction", 
49 function () {
50 return true;
51 });
52 Clazz.pu$h(self.c$);
53 c$ = Clazz.declareType (javax.swing.JToggleButton, "ToggleButtonModel", javax.swing.DefaultButtonModel);
54 Clazz.makeConstructor (c$, 
55 function () {
56 Clazz.superConstructor (this, javax.swing.JToggleButton.ToggleButtonModel, []);
57 });
58 Clazz.overrideMethod (c$, "isSelected", 
59 function () {
60 return (this.stateMask & 2) != 0;
61 });
62 Clazz.overrideMethod (c$, "setSelected", 
63 function (a) {
64 var b = this.getGroup ();
65 if (b != null) {
66 b.setSelected (this, a);
67 a = b.isSelected (this);
68 }if (this.isSelected () == a) {
69 return;
70 }if (a) {
71 this.stateMask |= 2;
72 } else {
73 this.stateMask &= -3;
74 }this.fireStateChanged ();
75 this.fireItemStateChanged ( new java.awt.event.ItemEvent (this, 701, this, this.isSelected () ? 1 : 2));
76 }, "~B");
77 Clazz.overrideMethod (c$, "setPressed", 
78 function (a) {
79 if ((this.isPressed () == a) || !this.isEnabled ()) {
80 return;
81 }if (a == false && this.isArmed ()) {
82 this.setSelected (!this.isSelected ());
83 }if (a) {
84 this.stateMask |= 4;
85 } else {
86 this.stateMask &= -5;
87 }this.fireStateChanged ();
88 if (!this.isPressed () && this.isArmed ()) {
89 var b = 0;
90 var c = java.awt.EventQueue.getCurrentEvent ();
91 if (Clazz.instanceOf (c, java.awt.event.InputEvent)) {
92 b = (c).getModifiers ();
93 } else if (Clazz.instanceOf (c, java.awt.event.ActionEvent)) {
94 b = (c).getModifiers ();
95 }this.fireActionPerformed ( new java.awt.event.ActionEvent (this, 1001, this.getActionCommand (), java.awt.EventQueue.getMostRecentEventTime (), b));
96 }}, "~B");
97 c$ = Clazz.p0p ();
98 Clazz.defineStatics (c$,
99 "$uiClassID", "ToggleButtonUI");
100 });