src/solaris/classes/sun/awt/X11/XTextFieldPeer.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2007, 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. Oracle designates this --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 55,104 **** import sun.util.logging.PlatformLogger; import sun.awt.CausedFocusEvent; import sun.awt.AWTAccessor; ! public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField"); ! String text; ! XAWTTextField xtext; ! boolean firstChangeSkipped; ! ! public 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()); } else setEchoChar((char)0); ! start = txt.getSelectionStart(); ! end = txt.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); ! setEditable(txt.isEditable()); // After this line we should not change the component's text firstChangeSkipped = true; } --- 55,98 ---- import sun.util.logging.PlatformLogger; import sun.awt.CausedFocusEvent; import sun.awt.AWTAccessor; ! final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField"); ! private String text; ! private final XAWTTextField xtext; ! private final boolean firstChangeSkipped; ! XTextFieldPeer(TextField target) { super(target); text = target.getText(); xtext = new XAWTTextField(text,this, target.getParent()); xtext.getDocument().addDocumentListener(xtext); xtext.setCursor(target.getCursor()); XToolkit.specialPeerMap.put(xtext,this); initTextField(); ! setText(target.getText()); ! if (target.echoCharIsSet()) { ! setEchoChar(target.getEchoChar()); } else setEchoChar((char)0); ! 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 ! setCaretPosition(Math.min(end, text.length())); ! if (end > start) { ! select(start, end); ! } ! setEditable(target.isEditable()); // After this line we should not change the component's text firstChangeSkipped = true; }
*** 217,227 **** public void setText(String txt) { setXAWTTextField(txt); repaint(); } ! protected boolean setXAWTTextField(String txt) { text = txt; if (xtext != null) { // JTextField.setText() posts two different events (remove & insert). // Since we make no differences between text events, // the document listener has to be disabled while --- 211,221 ---- public void setText(String txt) { setXAWTTextField(txt); repaint(); } ! private boolean setXAWTTextField(String txt) { text = txt; if (xtext != null) { // JTextField.setText() posts two different events (remove & insert). // Since we make no differences between text events, // the document listener has to be disabled while