-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_95
Name: ccC48265 Date: 01/25/98
TextArea.append only appends one character
Create a TextArea and call append(). Only the first character of the supplied
string is appended to the text.
To see this bug in action, run the TextMirror class. Press
the button labeled 'Append "abcdef"'. It should append
the string "abcdef" to the bottom TextArea. Instead, only
"a" shows up. If you try this test in JDK 1.1.5, it works.
--------------------
import java.awt.*;
import java.awt.event.*;
public class TextMirror
extends Frame
implements KeyListener, ActionListener {
public TextMirror() {
super("TextMirror 1.0");
createUI();
wireEvents();
setVisible(true);
}
protected TextArea mSendArea, mReceiveArea;
protected CheckboxGroup mNewlineGroup;
protected Checkbox mRCheck, mNCheck, mRNCheck;
protected Button mAppendButton;
protected void createUI() {
setFont(new Font("TimesRoman", Font.PLAIN, 12));
setSize(320, 300);
setLocation(100, 100);
setLayout(new BorderLayout());
Panel p;
p = new Panel(new GridLayout(2, 1));
p.add(mSendArea = new TextArea(40, 12));
p.add(mReceiveArea = new TextArea(40, 12));
mReceiveArea.setEditable(false);
add(p, BorderLayout.CENTER);
p = new Panel(new FlowLayout());
mNewlineGroup = new CheckboxGroup();
p.add(mRCheck = new Checkbox("\\r", mNewlineGroup, true));
p.add(mNCheck = new Checkbox("\\n", mNewlineGroup, false));
p.add(mRNCheck = new Checkbox("\\r\\n", mNewlineGroup, false));
p.add(mAppendButton = new Button("append(\"abcdef\")"));
add(p, BorderLayout.SOUTH);
}
protected void wireEvents() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
mSendArea.addKeyListener(this);
mAppendButton.addActionListener(this);
}
public void keyPressed(KeyEvent ke) {}
public void keyReleased(KeyEvent ke) {}
public void keyTyped(KeyEvent ke) {
char c = ke.getKeyChar();
if (c == '\n' || c == '\r') {
String printable = (c == '\n') ? "\\n" : "\\r";
System.out.println("newline was received as " + printable);
Checkbox check = mNewlineGroup.getSelectedCheckbox();
String newline = null;
if (check == mRCheck) newline = "\r";
else if (check == mNCheck) newline = "\n";
else if (check == mRNCheck) newline = "\r\n";
mReceiveArea.append(newline);
}
else
mReceiveArea.append(new String(new char[] { c }));
}
public void actionPerformed(ActionEvent ae) {
mReceiveArea.append("abcdef");
}
public static void main(String[] args) {
new TextMirror();
}
}
###@###.### (Jan 25, 1998):
This bug can be reproduced exactly as described with both JDK1.2beta2-Z
and JDK1.2beta3-D ("D" was the latest beta3 version at the time of testing).
For Solaris platforms, on the other hand, the application works fine, i.e.,
as one would expect.
(Review ID: 23827)
======================================================================
- duplicates
-
JDK-4068143 TextArea.append doesn't work on Windows 95 (after initial screen drawing)
-
- Closed
-