3e661929be21c76ba8e2057050185186d1107c0e
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JPasswordField.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["javax.swing.JTextField"], "javax.swing.JPasswordField", ["javax.swing.text.Segment"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.echoChar = '\0';\r
5 this.echoCharSet = false;\r
6 Clazz.instantialize (this, arguments);\r
7 }, javax.swing, "JPasswordField", javax.swing.JTextField);\r
8 Clazz.makeConstructor (c$, \r
9 function () {\r
10 this.construct (null, null, 0);\r
11 });\r
12 Clazz.makeConstructor (c$, \r
13 function (text) {\r
14 this.construct (null, text, 0);\r
15 }, "~S");\r
16 Clazz.makeConstructor (c$, \r
17 function (columns) {\r
18 this.construct (null, null, columns);\r
19 }, "~N");\r
20 Clazz.makeConstructor (c$, \r
21 function (text, columns) {\r
22 this.construct (null, text, columns);\r
23 }, "~S,~N");\r
24 Clazz.overrideMethod (c$, "getUIClassID", \r
25 function () {\r
26 return "PasswordFieldUI";\r
27 });\r
28 Clazz.defineMethod (c$, "updateUI", \r
29 function () {\r
30 if (!this.echoCharSet) {\r
31 this.echoChar = '*';\r
32 }Clazz.superCall (this, javax.swing.JPasswordField, "updateUI", []);\r
33 });\r
34 Clazz.defineMethod (c$, "getEchoChar", \r
35 function () {\r
36 return this.echoChar;\r
37 });\r
38 Clazz.defineMethod (c$, "setEchoChar", \r
39 function (c) {\r
40 this.echoChar = c;\r
41 this.echoCharSet = true;\r
42 this.repaint ();\r
43 this.revalidate ();\r
44 }, "~S");\r
45 Clazz.defineMethod (c$, "echoCharIsSet", \r
46 function () {\r
47 return this.echoChar.charCodeAt (0) != 0;\r
48 });\r
49 Clazz.overrideMethod (c$, "cut", \r
50 function () {\r
51 });\r
52 Clazz.overrideMethod (c$, "copy", \r
53 function () {\r
54 });\r
55 Clazz.defineMethod (c$, "getPassword", \r
56 function () {\r
57 var doc = this.getDocument ();\r
58 var txt =  new javax.swing.text.Segment ();\r
59 try {\r
60 doc.getText (0, doc.getLength (), txt);\r
61 } catch (e) {\r
62 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {\r
63 return null;\r
64 } else {\r
65 throw e;\r
66 }\r
67 }\r
68 var retValue =  Clazz.newCharArray (txt.count, '\0');\r
69 System.arraycopy (txt.array, txt.offset, retValue, 0, txt.count);\r
70 return retValue;\r
71 });\r
72 Clazz.defineMethod (c$, "paramString", \r
73 function () {\r
74 return Clazz.superCall (this, javax.swing.JPasswordField, "paramString", []) + ",echoChar=" + this.echoChar;\r
75 });\r
76 Clazz.defineMethod (c$, "customSetUIProperty", \r
77 function (propertyName, value) {\r
78 if (propertyName === "echoChar") {\r
79 if (!this.echoCharSet) {\r
80 this.setEchoChar ((value).charValue ());\r
81 this.echoCharSet = false;\r
82 }return true;\r
83 }return false;\r
84 }, "~S,~O");\r
85 Clazz.defineStatics (c$,\r
86 "$$uiClassID", "PasswordFieldUI");\r
87 });\r