-
Bug
-
Resolution: Fixed
-
P2
-
1.1
-
None
-
1.1.1
-
x86
-
windows_95
-
Not verified
Name: mc57594 Date: 01/28/97
combining a PrintWriter and a TextArea results in mangled
output in a textarea. This does not happen under the JDK1.1b3
for Solaris. I've included an example source, listed below.
--8<-----------------------------------------------------------------------
/*
* TextAreaBug.java
*
* Copyright (C) 1997 Raymond Penners
*
* Time-stamp: <97/01/26 15:06:03 raymondp>
*/
/* java version "JDK1.1beta3.3" on Windows'95:
Run it and press "test" repeatedly. You will see some text being
appended in the TextArea, but you'll also notice that sometimes
garbage appears. This does _not_ happen under JDK1.1b3 for Solaris.
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class TextAreaWriter extends Writer
{
TextArea textArea;
public TextAreaWriter (TextArea txt)
{
textArea = txt;
}
public void write (char b[], int off, int len)
{
String s = new String (b, off, len);
textArea.append (s);
}
public void flush ()
{
}
public void close ()
{
}
}
class TextAreaBug extends Frame implements ActionListener
{
TextArea textArea;
TextAreaWriter twout;
PrintWriter out;
public TextAreaBug ()
{
super ();
setSize (600,400);
setTitle ("Press TEST repeatedly to see garbled output");
setLayout (new BorderLayout ());
textArea = new TextArea ();
twout = new TextAreaWriter (textArea);
out = new PrintWriter (twout);
add (textArea);
Panel toolbar = new Panel ();
toolbar.setLayout (new FlowLayout (FlowLayout.LEFT));
Button testButton = new Button ("test");
testButton.addActionListener (this);
Button quitButton = new Button ("quit");
quitButton.addActionListener (this);
toolbar.add (testButton);
toolbar.add (quitButton);
add ("North", toolbar);
}
public void actionPerformed (ActionEvent e)
{
String s = e.getActionCommand ();
if (s.equals ("test"))
{
out.println ("");
out.println ("Garbage appears mostly at beginning/end of lines.");
out.println ("");
out.println ("Please press TEST\nsome more and you");
out.println ("will see\n garbage appearing\n among this text");
}
else if (s.equals ("quit"))
System.exit (0);
}
public static void main (String args[])
{
TextAreaBug frame = new TextAreaBug ();
frame.setVisible (true);
}
}
--8<-----------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4027077 TextArea.append()
-
- Closed
-