66
67 XTextFieldPeer(TextField target) {
68 super(target);
69 text = target.getText();
70 xtext = new XAWTTextField(text,this, target.getParent());
71 xtext.getDocument().addDocumentListener(xtext);
72 xtext.setCursor(target.getCursor());
73 XToolkit.specialPeerMap.put(xtext,this);
74
75 initTextField();
76 setText(target.getText());
77 if (target.echoCharIsSet()) {
78 setEchoChar(target.getEchoChar());
79 }
80 else setEchoChar((char)0);
81
82 int start = target.getSelectionStart();
83 int end = target.getSelectionEnd();
84 // Fix for 5100200
85 // Restoring Motif behaviour
86 // Since the end position of the selected text can be greater then the length of the text,
87 // so we should set caret to max position of the text
88 setCaretPosition(Math.min(end, text.length()));
89 if (end > start) {
90 // Should be called after setText() and setCaretPosition()
91 select(start, end);
92 }
93
94 setEditable(target.isEditable());
95
96 // After this line we should not change the component's text
97 firstChangeSkipped = true;
98 AWTAccessor.getComponentAccessor().setPeer(xtext, this);
99 }
100
101 @Override
102 public void dispose() {
103 XToolkit.specialPeerMap.remove(xtext);
104 // visible caret has a timer thread which must be stopped
105 xtext.getCaret().setVisible(false);
106 super.dispose();
|
66
67 XTextFieldPeer(TextField target) {
68 super(target);
69 text = target.getText();
70 xtext = new XAWTTextField(text,this, target.getParent());
71 xtext.getDocument().addDocumentListener(xtext);
72 xtext.setCursor(target.getCursor());
73 XToolkit.specialPeerMap.put(xtext,this);
74
75 initTextField();
76 setText(target.getText());
77 if (target.echoCharIsSet()) {
78 setEchoChar(target.getEchoChar());
79 }
80 else setEchoChar((char)0);
81
82 int start = target.getSelectionStart();
83 int end = target.getSelectionEnd();
84 // Fix for 5100200
85 // Restoring Motif behaviour
86 // Since the end position of the selected text can be greater than the length of the text,
87 // so we should set caret to max position of the text
88 setCaretPosition(Math.min(end, text.length()));
89 if (end > start) {
90 // Should be called after setText() and setCaretPosition()
91 select(start, end);
92 }
93
94 setEditable(target.isEditable());
95
96 // After this line we should not change the component's text
97 firstChangeSkipped = true;
98 AWTAccessor.getComponentAccessor().setPeer(xtext, this);
99 }
100
101 @Override
102 public void dispose() {
103 XToolkit.specialPeerMap.remove(xtext);
104 // visible caret has a timer thread which must be stopped
105 xtext.getCaret().setVisible(false);
106 super.dispose();
|