--- old/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java 2013-09-26 16:21:00.677112500 +0400 +++ new/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java 2013-09-26 16:21:00.418079600 +0400 @@ -71,13 +71,13 @@ } setEditable(getTarget().isEditable()); setText(getTarget().getText()); + setCaretPosition(getTarget().getCaretPosition()); getTarget().addInputMethodListener(this); final int start = getTarget().getSelectionStart(); final int end = getTarget().getSelectionEnd(); if (end > start) { select(start, end); } - setCaretPosition(getTarget().getCaretPosition()); firstChangeSkipped = true; } --- old/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java 2013-09-26 16:21:02.975904500 +0400 +++ new/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java 2013-09-26 16:21:02.690868300 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,16 +64,14 @@ import sun.awt.SunToolkit; -class XTextAreaPeer extends XComponentPeer implements TextAreaPeer { - boolean editable; +final class XTextAreaPeer extends XComponentPeer implements TextAreaPeer { - AWTTextPane textPane; - AWTTextArea jtext; + private final AWTTextPane textPane; + private final AWTTextArea jtext; + private final boolean firstChangeSkipped; - boolean firstChangeSkipped; - - private final JavaMouseEventHandler javaMouseEventHandler - = new JavaMouseEventHandler( this ); + private final JavaMouseEventHandler javaMouseEventHandler = + new JavaMouseEventHandler(this); /* FIXME */ @@ -98,7 +96,7 @@ * Create a Text area. */ XTextAreaPeer(TextArea target) { - super( target ); + super(target); // some initializations require that target be set even // though init(target) has not been called @@ -106,8 +104,7 @@ //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK); - firstChangeSkipped = false; - String text = ((TextArea)target).getText(); + String text = target.getText(); jtext = new AWTTextArea(text, this); jtext.setWrapStyleWord(true); jtext.getDocument().addDocumentListener(jtext); @@ -143,25 +140,21 @@ setFont(font); + // set the text of this object to the text of its target + setTextImpl(target.getText()); //?? should this be setText + int start = target.getSelectionStart(); int end = target.getSelectionEnd(); - - if (end > start) { - select(start, end); - } // Fix for 5100200 // Restoring Motif behaviour // Since the end position of the selected text can be greater then the length of the text, // so we should set caret to max position of the text - int caretPosition = Math.min(end, text.length()); - setCaretPosition(caretPosition); - + setCaretPosition(Math.min(end, text.length())); + if (end > start) { + select(start, end); + } setEditable(target.isEditable()); - setScrollBarVisibility(); - // set the text of this object to the text of its target - setTextImpl(target.getText()); //?? should this be setText - // After this line we should not change the component's text firstChangeSkipped = true; } @@ -408,7 +401,6 @@ * @see java.awt.peer.TextComponentPeer */ public void setEditable(boolean editable) { - this.editable = editable; if (jtext != null) jtext.setEditable(editable); repaintText(); } @@ -461,7 +453,7 @@ repaintText(); } - protected boolean setTextImpl(String txt) { + private void setTextImpl(String txt) { if (jtext != null) { // JTextArea.setText() posts two different events (remove & insert). // Since we make no differences between text events, @@ -474,7 +466,6 @@ } jtext.getDocument().addDocumentListener(jtext); } - return true; } /** --- old/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java 2013-09-26 16:21:05.610739000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java 2013-09-26 16:21:05.326202900 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,46 +57,40 @@ import sun.awt.CausedFocusEvent; import sun.awt.AWTAccessor; -public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer { +final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField"); - String text; - XAWTTextField xtext; + private String text; + private final XAWTTextField xtext; + private final boolean firstChangeSkipped; - boolean firstChangeSkipped; - - public XTextFieldPeer(TextField target) { + XTextFieldPeer(TextField target) { super(target); - int start, end; - firstChangeSkipped = false; text = target.getText(); xtext = new XAWTTextField(text,this, target.getParent()); xtext.getDocument().addDocumentListener(xtext); xtext.setCursor(target.getCursor()); XToolkit.specialPeerMap.put(xtext,this); - TextField txt = (TextField) target; initTextField(); - setText(txt.getText()); - if (txt.echoCharIsSet()) { - setEchoChar(txt.getEchoChar()); + setText(target.getText()); + if (target.echoCharIsSet()) { + setEchoChar(target.getEchoChar()); } else setEchoChar((char)0); - start = txt.getSelectionStart(); - end = txt.getSelectionEnd(); - - if (end > start) { - select(start, end); - } + int start = target.getSelectionStart(); + int end = target.getSelectionEnd(); // Fix for 5100200 // Restoring Motif behaviour // Since the end position of the selected text can be greater then the length of the text, // so we should set caret to max position of the text - int caretPosition = Math.min(end, text.length()); - setCaretPosition(caretPosition); + setCaretPosition(Math.min(end, text.length())); + if (end > start) { + select(start, end); + } - setEditable(txt.isEditable()); + setEditable(target.isEditable()); // After this line we should not change the component's text firstChangeSkipped = true; @@ -219,7 +213,7 @@ repaint(); } - protected boolean setXAWTTextField(String txt) { + private boolean setXAWTTextField(String txt) { text = txt; if (xtext != null) { // JTextField.setText() posts two different events (remove & insert). --- /dev/null 2013-09-26 16:21:08.000000000 +0400 +++ new/test/java/awt/TextArea/SelectionVisible/SelectionVisible.html 2013-09-26 16:21:07.590990500 +0400 @@ -0,0 +1,42 @@ + + + + + + SelectionVisible + + + +

SelectionVisible
Bugid: 4082144

+ + + + --- /dev/null 2013-09-26 16:21:09.000000000 +0400 +++ new/test/java/awt/TextArea/SelectionVisible/SelectionVisible.java 2013-09-26 16:21:09.289206100 +0400 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Panel; +import java.awt.TextArea; + +public final class SelectionVisible extends Applet { + + TextArea tf; + + @Override + public void init() { + tf = new TextArea(3, 20); + tf.setText("0123456789"); + tf.select(0, 6); + + final TextArea ta = new TextArea("INSTRUCTIONS:\n" + + "The text 012345 should be selected in the TextArea.\n" + + "If this is what you observe, then the test passes.\n" + + "Otherwise, the test fails.", 40, 5, + TextArea.SCROLLBARS_NONE); + ta.setEditable(false); + ta.setPreferredSize(new Dimension(300, 70)); + final Panel panel = new Panel(); + panel.setLayout(new FlowLayout()); + panel.add(tf); + setLayout(new BorderLayout()); + add(ta, BorderLayout.CENTER); + add(panel, BorderLayout.PAGE_END); + } + + @Override + public void start() { + setVisible(true); + tf.requestFocus(); + } +} --- /dev/null 2013-09-26 16:21:11.000000000 +0400 +++ new/test/java/awt/TextField/SelectionVisible/SelectionVisible.html 2013-09-26 16:21:11.032927600 +0400 @@ -0,0 +1,42 @@ + + + + + + SelectionVisible + + + +

SelectionVisible
Bugid: 4082144

+ + + + --- /dev/null 2013-09-26 16:21:13.000000000 +0400 +++ new/test/java/awt/TextField/SelectionVisible/SelectionVisible.java 2013-09-26 16:21:12.711640700 +0400 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.TextField; + +public final class SelectionVisible extends Applet { + + TextField tf; + + @Override + public void init() { + tf = new TextField(20); + tf.setText("0123456789"); + tf.select(0, 6); + + final TextArea ta = new TextArea("INSTRUCTIONS:\n" + + "The text 012345 should be selected in the TextField.\n" + + "If this is what you observe, then the test passes.\n" + + "Otherwise, the test fails.", 40, 5, + TextArea.SCROLLBARS_NONE); + ta.setEditable(false); + ta.setPreferredSize(new Dimension(300, 70)); + final Panel panel = new Panel(); + panel.setLayout(new FlowLayout()); + panel.add(tf); + setLayout(new BorderLayout()); + add(ta, BorderLayout.CENTER); + add(panel, BorderLayout.PAGE_END); + } + + @Override + public void start() { + setVisible(true); + tf.requestFocus(); + } +}