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