7d1116ad5ab1c202930f6ecbcd6793341b9d2b58
[jalviewjs.git] / site / j2s / javax / swing / JMenuBar.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent", "$.MenuElement"], "javax.swing.JMenuBar", ["java.lang.Error", "java.util.Vector", "java.awt.Insets", "javax.swing.DefaultSingleSelectionModel", "$.JMenu", "$.JPopupMenu", "$.KeyboardManager", "$.UIManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.selectionModel = null;
5 this.$paintBorder = true;
6 this.margin = null;
7 Clazz.instantialize (this, arguments);
8 }, javax.swing, "JMenuBar", javax.swing.JComponent, javax.swing.MenuElement);
9 Clazz.makeConstructor (c$, 
10 function () {
11 Clazz.superConstructor (this, javax.swing.JMenuBar);
12 this.setSelectionModel ( new javax.swing.DefaultSingleSelectionModel ());
13 this.updateUI ();
14 });
15 Clazz.overrideMethod (c$, "getUI", 
16 function () {
17 return this.ui;
18 });
19 Clazz.overrideMethod (c$, "updateUI", 
20 function () {
21 this.setUI (javax.swing.UIManager.getUI (this));
22 });
23 Clazz.overrideMethod (c$, "getUIClassID", 
24 function () {
25 return "MenuBarUI";
26 });
27 Clazz.defineMethod (c$, "getSelectionModel", 
28 function () {
29 return this.selectionModel;
30 });
31 Clazz.defineMethod (c$, "setSelectionModel", 
32 function (model) {
33 var oldValue = this.selectionModel;
34 this.selectionModel = model;
35 this.firePropertyChangeObject ("selectionModel", oldValue, this.selectionModel);
36 }, "javax.swing.SingleSelectionModel");
37 Clazz.defineMethod (c$, "add", 
38 function (c) {
39 Clazz.superCall (this, javax.swing.JMenuBar, "add", [c]);
40 return c;
41 }, "javax.swing.JMenu");
42 Clazz.defineMethod (c$, "getMenu", 
43 function (index) {
44 var c = this.getComponentAtIndex (index);
45 if (Clazz.instanceOf (c, javax.swing.JMenu)) return c;
46 return null;
47 }, "~N");
48 Clazz.defineMethod (c$, "getMenuCount", 
49 function () {
50 return this.getComponentCount ();
51 });
52 Clazz.defineMethod (c$, "setHelpMenu", 
53 function (menu) {
54 throw  new Error ("setHelpMenu() not yet implemented.");
55 }, "javax.swing.JMenu");
56 Clazz.defineMethod (c$, "getHelpMenu", 
57 function () {
58 throw  new Error ("getHelpMenu() not yet implemented.");
59 });
60 Clazz.defineMethod (c$, "getComponentAtIndex", 
61 function (i) {
62 if (i < 0 || i >= this.getComponentCount ()) {
63 return null;
64 }return this.getComponent (i);
65 }, "~N");
66 Clazz.defineMethod (c$, "getComponentIndex", 
67 function (c) {
68 var ncomponents = this.getComponentCount ();
69 var component = this.getComponents ();
70 for (var i = 0; i < ncomponents; i++) {
71 var comp = component[i];
72 if (comp === c) return i;
73 }
74 return -1;
75 }, "java.awt.Component");
76 Clazz.defineMethod (c$, "setSelected", 
77 function (sel) {
78 var model = this.getSelectionModel ();
79 var index = this.getComponentIndex (sel);
80 model.setSelectedIndex (index);
81 }, "java.awt.Component");
82 Clazz.defineMethod (c$, "isSelected", 
83 function () {
84 return this.selectionModel.isSelected ();
85 });
86 Clazz.defineMethod (c$, "isBorderPainted", 
87 function () {
88 return this.$paintBorder;
89 });
90 Clazz.defineMethod (c$, "setBorderPainted", 
91 function (b) {
92 var oldValue = this.$paintBorder;
93 this.$paintBorder = b;
94 this.firePropertyChangeBool ("borderPainted", oldValue, this.$paintBorder);
95 if (b != oldValue) {
96 this.revalidate ();
97 this.repaint ();
98 }}, "~B");
99 Clazz.defineMethod (c$, "paintBorder", 
100 function (g) {
101 if (this.isBorderPainted ()) {
102 Clazz.superCall (this, javax.swing.JMenuBar, "paintBorder", [g]);
103 }}, "java.awt.Graphics");
104 Clazz.defineMethod (c$, "setMargin", 
105 function (m) {
106 var old = this.margin;
107 this.margin = m;
108 this.firePropertyChangeObject ("margin", old, m);
109 if (old == null || !old.equals (m)) {
110 this.revalidate ();
111 this.repaint ();
112 }}, "java.awt.Insets");
113 Clazz.defineMethod (c$, "getMargin", 
114 function () {
115 if (this.margin == null) {
116 return  new java.awt.Insets (0, 0, 0, 0);
117 } else {
118 return this.margin;
119 }});
120 Clazz.defineMethod (c$, "processMouseEvent", 
121 function (event, path, manager) {
122 }, "java.awt.event.MouseEvent,~A,javax.swing.MenuSelectionManager");
123 Clazz.defineMethod (c$, "processKeyEvent", 
124 function (e, path, manager) {
125 }, "java.awt.event.KeyEvent,~A,javax.swing.MenuSelectionManager");
126 Clazz.overrideMethod (c$, "menuSelectionChanged", 
127 function (isIncluded) {
128 }, "~B");
129 Clazz.defineMethod (c$, "getSubElements", 
130 function () {
131 var result;
132 var tmp =  new java.util.Vector ();
133 var c = this.getComponentCount ();
134 var i;
135 var m;
136 for (i = 0; i < c; i++) {
137 m = this.getComponent (i);
138 if (Clazz.instanceOf (m, javax.swing.MenuElement)) tmp.addElement (m);
139 }
140 result =  new Array (tmp.size ());
141 for (i = 0, c = tmp.size (); i < c; i++) result[i] = tmp.elementAt (i);
142
143 return result;
144 });
145 Clazz.defineMethod (c$, "getComponent", 
146 function () {
147 return this;
148 });
149 Clazz.defineMethod (c$, "paramString", 
150 function () {
151 var paintBorderString = (this.$paintBorder ? "true" : "false");
152 var marginString = (this.margin != null ? this.margin.toString () : "");
153 return Clazz.superCall (this, javax.swing.JMenuBar, "paramString", []) + ",margin=" + marginString + ",paintBorder=" + paintBorderString;
154 });
155 Clazz.defineMethod (c$, "processKeyBinding", 
156 function (ks, e, condition, pressed) {
157 var retValue = Clazz.superCall (this, javax.swing.JMenuBar, "processKeyBinding", [ks, e, condition, pressed]);
158 if (!retValue) {
159 var subElements = this.getSubElements ();
160 for (var i = 0; i < subElements.length; i++) {
161 if (javax.swing.JMenuBar.processBindingForKeyStrokeRecursive (subElements[i], ks, e, condition, pressed)) {
162 return true;
163 }}
164 }return retValue;
165 }, "javax.swing.KeyStroke,java.awt.event.KeyEvent,~N,~B");
166 c$.processBindingForKeyStrokeRecursive = Clazz.defineMethod (c$, "processBindingForKeyStrokeRecursive", 
167 function (elem, ks, e, condition, pressed) {
168 if (elem == null) {
169 return false;
170 }var c = elem.getComponent ();
171 if (!(c.isVisible () || (Clazz.instanceOf (c, javax.swing.JPopupMenu))) || !c.isEnabled ()) {
172 return false;
173 }if (c != null && Clazz.instanceOf (c, javax.swing.JComponent) && (c).processKeyBinding (ks, e, condition, pressed)) {
174 return true;
175 }var subElements = elem.getSubElements ();
176 for (var i = 0; i < subElements.length; i++) {
177 if (javax.swing.JMenuBar.processBindingForKeyStrokeRecursive (subElements[i], ks, e, condition, pressed)) {
178 return true;
179 }}
180 return false;
181 }, "javax.swing.MenuElement,javax.swing.KeyStroke,java.awt.event.KeyEvent,~N,~B");
182 Clazz.defineMethod (c$, "addNotify", 
183 function () {
184 Clazz.superCall (this, javax.swing.JMenuBar, "addNotify", []);
185 javax.swing.KeyboardManager.getCurrentManager ().registerMenuBar (this);
186 });
187 Clazz.defineMethod (c$, "removeNotify", 
188 function () {
189 Clazz.superCall (this, javax.swing.JMenuBar, "removeNotify", []);
190 javax.swing.KeyboardManager.getCurrentManager ().unregisterMenuBar (this);
191 });
192 Clazz.defineStatics (c$,
193 "$uiClassID", "MenuBarUI");
194 });