equal
deleted
inserted
replaced
227 * if this parameter is <code>null</code> then |
227 * if this parameter is <code>null</code> then |
228 * the text is set to the empty string "" |
228 * the text is set to the empty string "" |
229 * @see java.awt.TextComponent#getText |
229 * @see java.awt.TextComponent#getText |
230 */ |
230 */ |
231 public synchronized void setText(String t) { |
231 public synchronized void setText(String t) { |
232 boolean skipTextEvent = (text == null || text.isEmpty()) |
232 if (t == null) { |
233 && (t == null || t.isEmpty()); |
233 t = ""; |
234 text = (t != null) ? t : ""; |
234 } |
235 TextComponentPeer peer = (TextComponentPeer)this.peer; |
235 TextComponentPeer peer = (TextComponentPeer)this.peer; |
236 // Please note that we do not want to post an event |
236 if (peer != null) { |
237 // if TextArea.setText() or TextField.setText() replaces an empty text |
237 text = peer.getText(); |
238 // by an empty text, that is, if component's text remains unchanged. |
238 // Please note that we do not want to post an event |
239 if (peer != null && !skipTextEvent) { |
239 // if TextArea.setText() or TextField.setText() replaces text |
240 peer.setText(text); |
240 // by same text, that is, if component's text remains unchanged. |
|
241 if (!t.equals(text)) { |
|
242 text = t; |
|
243 peer.setText(text); |
|
244 } |
|
245 } else { |
|
246 text = t; |
241 } |
247 } |
242 } |
248 } |
243 |
249 |
244 /** |
250 /** |
245 * Returns the text that is presented by this text component. |
251 * Returns the text that is presented by this text component. |