1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.ActionPropertyChangeListener", "$.SwingConstants", "javax.swing.event.ChangeListener", "javax.swing.text.JTextComponent", "$.TextAction"], "javax.swing.JTextField", ["java.lang.Boolean", "$.IllegalArgumentException", "java.awt.EventQueue", "java.awt.event.ActionEvent", "$.ActionListener", "$.InputEvent", "javax.swing.AbstractAction", "$.JViewport", "swingjs.JSToolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.actionPropertyChangeListener = null;
6 this.horizontalAlignment = 10;
10 if (!Clazz.isClassDefined ("javax.swing.JTextField.ScrollRepainter")) {
11 javax.swing.JTextField.$JTextField$ScrollRepainter$ ();
13 Clazz.instantialize (this, arguments);
14 }, javax.swing, "JTextField", javax.swing.text.JTextComponent, javax.swing.SwingConstants);
15 Clazz.makeConstructor (c$,
17 this.construct (null, null, 0);
19 Clazz.makeConstructor (c$,
21 this.construct (null, text, 0);
23 Clazz.makeConstructor (c$,
25 this.construct (null, null, columns);
27 Clazz.makeConstructor (c$,
28 function (text, columns) {
29 this.construct (null, text, columns);
31 Clazz.makeConstructor (c$,
32 function (doc, text, columns) {
33 Clazz.superConstructor (this, javax.swing.JTextField);
35 throw new IllegalArgumentException ("columns less than zero.");
36 }this.columns = columns;
38 doc = this.createDefaultModel ();
39 }this.setDocument (doc);
42 }}, "javax.swing.text.Document,~S,~N");
43 Clazz.overrideMethod (c$, "getUIClassID",
47 Clazz.defineMethod (c$, "setDocument",
50 doc.putProperty ("filterNewlines", Boolean.TRUE);
51 }Clazz.superCall (this, javax.swing.JTextField, "setDocument", [doc]);
52 }, "javax.swing.text.Document");
53 Clazz.overrideMethod (c$, "isValidateRoot",
55 var parent = this.getParent ();
56 if (Clazz.instanceOf (parent, javax.swing.JViewport)) {
60 Clazz.defineMethod (c$, "getHorizontalAlignment",
62 return this.horizontalAlignment;
64 Clazz.defineMethod (c$, "setHorizontalAlignment",
65 function (alignment) {
66 if (alignment == this.horizontalAlignment) return;
67 var oldValue = this.horizontalAlignment;
68 if ((alignment == 2) || (alignment == 0) || (alignment == 4) || (alignment == 10) || (alignment == 11)) {
69 this.horizontalAlignment = alignment;
71 throw new IllegalArgumentException ("horizontalAlignment");
72 }this.firePropertyChangeInt ("horizontalAlignment", oldValue, this.horizontalAlignment);
76 Clazz.defineMethod (c$, "createDefaultModel",
78 return swingjs.JSToolkit.getPlainDocument (this);
80 Clazz.defineMethod (c$, "getColumns",
84 Clazz.defineMethod (c$, "setColumns",
86 var oldVal = this.columns;
88 throw new IllegalArgumentException ("columns less than zero.");
89 }if (columns != oldVal) {
90 this.columns = columns;
93 Clazz.defineMethod (c$, "getColumnWidth",
95 if (this.columnWidth == 0) {
96 var metrics = this.getFontMetrics (this.getFont ());
97 this.columnWidth = metrics.charWidth ('m');
98 }return this.columnWidth;
100 Clazz.overrideMethod (c$, "getPreferredSize",
102 return this.getPrefSizeJTF ();
104 Clazz.defineMethod (c$, "getPrefSizeJTF",
106 var size = this.getPrefSizeJComp ();
107 if (this.columns != 0) {
108 var insets = this.getInsets ();
109 size.width = this.columns * this.getColumnWidth () + insets.left + insets.right;
112 Clazz.defineMethod (c$, "setFont",
114 Clazz.superCall (this, javax.swing.JTextField, "setFont", [f]);
115 this.columnWidth = 0;
117 Clazz.defineMethod (c$, "addActionListener",
119 this.listenerList.add (java.awt.event.ActionListener, l);
120 }, "java.awt.event.ActionListener");
121 Clazz.defineMethod (c$, "removeActionListener",
123 if ((l != null) && (this.getAction () === l)) {
124 this.setAction (null);
126 this.listenerList.remove (java.awt.event.ActionListener, l);
127 }}, "java.awt.event.ActionListener");
128 Clazz.defineMethod (c$, "getActionListeners",
130 return this.listenerList.getListeners (java.awt.event.ActionListener);
132 Clazz.defineMethod (c$, "fireActionPerformed",
134 var listeners = this.listenerList.getListenerList ();
136 var currentEvent = java.awt.EventQueue.getCurrentEvent ();
137 if (Clazz.instanceOf (currentEvent, java.awt.event.InputEvent)) {
138 modifiers = (currentEvent).getModifiers ();
139 } else if (Clazz.instanceOf (currentEvent, java.awt.event.ActionEvent)) {
140 modifiers = (currentEvent).getModifiers ();
141 }var e = new java.awt.event.ActionEvent (this, 1001, (this.command != null) ? this.command : this.getText (), java.awt.EventQueue.getMostRecentEventTime (), modifiers);
142 for (var i = listeners.length - 2; i >= 0; i -= 2) {
143 if (listeners[i] === java.awt.event.ActionListener) {
144 (listeners[i + 1]).actionPerformed (e);
147 Clazz.defineMethod (c$, "setActionCommand",
149 this.command = command;
151 Clazz.defineMethod (c$, "setAction",
153 var oldValue = this.getAction ();
154 if (this.$action == null || !this.$action.equals (a)) {
156 if (oldValue != null) {
157 this.removeActionListener (oldValue);
158 oldValue.removePropertyChangeListener (this.actionPropertyChangeListener);
159 this.actionPropertyChangeListener = null;
160 }this.configurePropertiesFromAction (this.$action);
161 if (this.$action != null) {
162 if (!this.isListener (java.awt.event.ActionListener, this.$action)) {
163 this.addActionListener (this.$action);
164 }this.actionPropertyChangeListener = this.createActionPropertyChangeListener (this.$action);
165 this.$action.addPropertyChangeListener (this.actionPropertyChangeListener);
166 }this.firePropertyChangeObject ("action", oldValue, this.$action);
167 }}, "javax.swing.Action");
168 Clazz.defineMethod (c$, "isListener",
170 var isListener = false;
171 var listeners = this.listenerList.getListenerList ();
172 for (var i = listeners.length - 2; i >= 0; i -= 2) {
173 if (listeners[i] === c && listeners[i + 1] === a) {
177 }, "Class,java.awt.event.ActionListener");
178 Clazz.defineMethod (c$, "getAction",
182 Clazz.defineMethod (c$, "configurePropertiesFromAction",
184 javax.swing.AbstractAction.setEnabledFromAction (this, a);
185 javax.swing.AbstractAction.setToolTipTextFromAction (this, a);
186 this.setActionCommandFromAction (a);
187 }, "javax.swing.Action");
188 Clazz.defineMethod (c$, "actionPropertyChanged",
189 function (action, propertyName) {
190 if (propertyName === "ActionCommandKey") {
191 this.setActionCommandFromAction (action);
192 } else if (propertyName === "enabled") {
193 javax.swing.AbstractAction.setEnabledFromAction (this, action);
194 } else if (propertyName === "ShortDescription") {
195 javax.swing.AbstractAction.setToolTipTextFromAction (this, action);
196 }}, "javax.swing.Action,~S");
197 Clazz.defineMethod (c$, "setActionCommandFromAction",
199 this.setActionCommand ((action == null) ? null : action.getValue ("ActionCommandKey"));
200 }, "javax.swing.Action");
201 Clazz.defineMethod (c$, "createActionPropertyChangeListener",
203 return new javax.swing.JTextField.TextFieldActionPropertyChangeListener (this, a);
204 }, "javax.swing.Action");
205 Clazz.defineMethod (c$, "getActions",
207 return javax.swing.text.TextAction.augmentList (Clazz.superCall (this, javax.swing.JTextField, "getActions", []), javax.swing.JTextField.defaultActions);
209 Clazz.defineMethod (c$, "postActionEvent",
211 this.fireActionPerformed ();
213 Clazz.defineMethod (c$, "hasActionListener",
215 var listeners = this.listenerList.getListenerList ();
216 for (var i = listeners.length - 2; i >= 0; i -= 2) {
217 if (listeners[i] === java.awt.event.ActionListener) {
222 Clazz.defineMethod (c$, "paramString",
224 var horizontalAlignmentString;
225 if (this.horizontalAlignment == 2) {
226 horizontalAlignmentString = "LEFT";
227 } else if (this.horizontalAlignment == 0) {
228 horizontalAlignmentString = "CENTER";
229 } else if (this.horizontalAlignment == 4) {
230 horizontalAlignmentString = "RIGHT";
231 } else if (this.horizontalAlignment == 10) {
232 horizontalAlignmentString = "LEADING";
233 } else if (this.horizontalAlignment == 11) {
234 horizontalAlignmentString = "TRAILING";
235 } else horizontalAlignmentString = "";
236 var commandString = (this.command != null ? this.command : "");
237 return Clazz.superCall (this, javax.swing.JTextField, "paramString", []) + ",columns=" + this.columns + ",columnWidth=" + this.columnWidth + ",command=" + commandString + ",horizontalAlignment=" + horizontalAlignmentString;
239 c$.$JTextField$ScrollRepainter$ = function () {
241 c$ = Clazz.decorateAsClass (function () {
242 Clazz.prepareCallback (this, arguments);
243 Clazz.instantialize (this, arguments);
244 }, javax.swing.JTextField, "ScrollRepainter", null, javax.swing.event.ChangeListener);
245 Clazz.overrideMethod (c$, "stateChanged",
247 this.b$["javax.swing.JTextField"].repaint ();
248 }, "javax.swing.event.ChangeEvent");
252 c$ = Clazz.declareType (javax.swing.JTextField, "TextFieldActionPropertyChangeListener", javax.swing.ActionPropertyChangeListener);
253 Clazz.overrideMethod (c$, "actionPropertyChanged",
255 if (javax.swing.AbstractAction.shouldReconfigure (c)) {
256 a.configurePropertiesFromAction (b);
258 a.actionPropertyChanged (b, c.getPropertyName ());
259 }}, "javax.swing.JTextField,javax.swing.Action,java.beans.PropertyChangeEvent");
262 c$ = Clazz.declareType (javax.swing.JTextField, "NotifyAction", javax.swing.text.TextAction);
263 Clazz.makeConstructor (c$,
265 Clazz.superConstructor (this, javax.swing.JTextField.NotifyAction, ["notify-field-accept"]);
267 Clazz.overrideMethod (c$, "actionPerformed",
269 var b = this.getFocusedComponent ();
270 if (Clazz.instanceOf (b, javax.swing.JTextField)) {
272 c.postActionEvent ();
273 }}, "java.awt.event.ActionEvent");
274 Clazz.overrideMethod (c$, "isEnabled",
276 var a = this.getFocusedComponent ();
277 if (Clazz.instanceOf (a, javax.swing.JTextField)) {
278 return (a).hasActionListener ();
282 Clazz.defineStatics (c$,
283 "notifyAction", "notify-field-accept");
284 c$.defaultActions = c$.prototype.defaultActions = Clazz.newArray (-1, [ new javax.swing.JTextField.NotifyAction ()]);
285 Clazz.defineStatics (c$,
286 "$uiClassID", "TextFieldUI");