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