212 synchronized (getTreeLock()) {
213 TextComponentPeer peer = (TextComponentPeer)this.peer;
214 if (peer != null) {
215 text = peer.getText();
216 selectionStart = peer.getSelectionStart();
217 selectionEnd = peer.getSelectionEnd();
218 }
219 super.removeNotify();
220 }
221 }
222
223 /**
224 * Sets the text that is presented by this
225 * text component to be the specified text.
226 * @param t the new text;
227 * if this parameter is <code>null</code> then
228 * the text is set to the empty string ""
229 * @see java.awt.TextComponent#getText
230 */
231 public synchronized void setText(String t) {
232 boolean skipTextEvent = (text == null || text.isEmpty())
233 && (t == null || t.isEmpty());
234 text = (t != null) ? t : "";
235 TextComponentPeer peer = (TextComponentPeer)this.peer;
236 // Please note that we do not want to post an event
237 // if TextArea.setText() or TextField.setText() replaces an empty text
238 // by an empty text, that is, if component's text remains unchanged.
239 if (peer != null && !skipTextEvent) {
240 peer.setText(text);
241 }
242 }
243
244 /**
245 * Returns the text that is presented by this text component.
246 * By default, this is an empty string.
247 *
248 * @return the value of this <code>TextComponent</code>
249 * @see java.awt.TextComponent#setText
250 */
251 public synchronized String getText() {
252 TextComponentPeer peer = (TextComponentPeer)this.peer;
253 if (peer != null) {
254 text = peer.getText();
255 }
|
212 synchronized (getTreeLock()) {
213 TextComponentPeer peer = (TextComponentPeer)this.peer;
214 if (peer != null) {
215 text = peer.getText();
216 selectionStart = peer.getSelectionStart();
217 selectionEnd = peer.getSelectionEnd();
218 }
219 super.removeNotify();
220 }
221 }
222
223 /**
224 * Sets the text that is presented by this
225 * text component to be the specified text.
226 * @param t the new text;
227 * if this parameter is <code>null</code> then
228 * the text is set to the empty string ""
229 * @see java.awt.TextComponent#getText
230 */
231 public synchronized void setText(String t) {
232 TextComponentPeer peer = (TextComponentPeer)this.peer;
233 if (peer != null) {
234 text = peer.getText();
235 }
236
237 boolean skipTextEvent = (text == null || text.isEmpty())
238 && (t == null || t.isEmpty());
239 text = (t != null) ? t : "";
240 // Please note that we do not want to post an event
241 // if TextArea.setText() or TextField.setText() replaces an empty text
242 // by an empty text, that is, if component's text remains unchanged.
243 if (peer != null && !skipTextEvent) {
244 peer.setText(text);
245 }
246 }
247
248 /**
249 * Returns the text that is presented by this text component.
250 * By default, this is an empty string.
251 *
252 * @return the value of this <code>TextComponent</code>
253 * @see java.awt.TextComponent#setText
254 */
255 public synchronized String getText() {
256 TextComponentPeer peer = (TextComponentPeer)this.peer;
257 if (peer != null) {
258 text = peer.getText();
259 }
|