src/solaris/classes/sun/awt/X11/XTextAreaPeer.java
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -62,20 +62,18 @@
import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
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 */
public long filterEvents(long mask) {
Thread.dumpStack();
@@ -96,20 +94,19 @@
/**
* 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
this.target = target;
//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);
XToolkit.specialPeerMap.put(jtext,this);
textPane = new AWTTextPane(jtext,this, target.getParent());
@@ -141,29 +138,25 @@
target.setForeground(SystemColor.textText);
}
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;
}
public void dispose() {
@@ -406,11 +399,10 @@
/**
* @see java.awt.peer.TextComponentPeer
*/
public void setEditable(boolean editable) {
- this.editable = editable;
if (jtext != null) jtext.setEditable(editable);
repaintText();
}
/**
@@ -459,11 +451,11 @@
public void setText(String txt) {
setTextImpl(txt);
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,
// the document listener has to be disabled while
// JTextArea.setText() is called.
@@ -472,11 +464,10 @@
if (firstChangeSkipped) {
postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
}
jtext.getDocument().addDocumentListener(jtext);
}
- return true;
}
/**
* insert the text "txt on position "pos" in the array lines
* @see java.awt.peer.TextAreaPeer