--- old/src/java.desktop/share/classes/java/awt/TextComponent.java 2015-11-20 17:13:47.085080679 +0530 +++ new/src/java.desktop/share/classes/java/awt/TextComponent.java 2015-11-20 17:13:46.797080679 +0530 @@ -229,15 +229,18 @@ * @see java.awt.TextComponent#getText */ public synchronized void setText(String t) { - boolean skipTextEvent = (text == null || text.isEmpty()) - && (t == null || t.isEmpty()); - text = (t != null) ? t : ""; TextComponentPeer peer = (TextComponentPeer)this.peer; - // Please note that we do not want to post an event - // if TextArea.setText() or TextField.setText() replaces an empty text - // by an empty text, that is, if component's text remains unchanged. - if (peer != null && !skipTextEvent) { - peer.setText(text); + if (peer != null) { + text = peer.getText(); + boolean skipTextEvent = (text == null || text.isEmpty()) + && (t == null || t.isEmpty()); + text = (t != null) ? t : ""; + // Please note that we do not want to post an event + // if TextArea.setText() or TextField.setText() replaces an empty text + // by an empty text, that is, if component's text remains unchanged. + if (!skipTextEvent) { + peer.setText(text); + } } }