-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.1.2
-
None
-
sparc
-
solaris_2.5
JTextArea.setText(String) causes "java.lang.IllegalArgumentException : inconsistent values" while the TextArea has existing text created by JTextArea.append(String). This bug only show on Solaris but work
fine on Win32.
To reproduce the bug, please use the following code :
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
public class myTest extends JPanel
{
JTextArea tArea ;
public static void main(String[] args){
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
JFrame f = new JFrame();
f.addWindowListener(l);
f.add( new myTest());
f.pack();
f.show();
}
myTest() {
// --------------------------------------------------
// Create GUI components
// --------------------------------------------------
JButton startButton = new JButton("Start");
JButton clearButton = new JButton("Clear");
tArea = new JTextArea();
// Add Listener
startButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
byte[] ba = new byte[2];
FileInputStream ff = new FileInputStream("myTest.java");
while ( ff.read(ba) != -1 ) {
tArea.append(new String(ba) );
}
}catch ( Exception ee ) {
ee.printStackTrace();
}
}
});
clearButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
tArea.setText("");
}
});
// layout
this.setLayout(new BorderLayout());
this.add("North", startButton);
this.add("Center", tArea);
this.add("South",clearButton);
}
}
fine on Win32.
To reproduce the bug, please use the following code :
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
public class myTest extends JPanel
{
JTextArea tArea ;
public static void main(String[] args){
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
JFrame f = new JFrame();
f.addWindowListener(l);
f.add( new myTest());
f.pack();
f.show();
}
myTest() {
// --------------------------------------------------
// Create GUI components
// --------------------------------------------------
JButton startButton = new JButton("Start");
JButton clearButton = new JButton("Clear");
tArea = new JTextArea();
// Add Listener
startButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
byte[] ba = new byte[2];
FileInputStream ff = new FileInputStream("myTest.java");
while ( ff.read(ba) != -1 ) {
tArea.append(new String(ba) );
}
}catch ( Exception ee ) {
ee.printStackTrace();
}
}
});
clearButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
tArea.setText("");
}
});
// layout
this.setLayout(new BorderLayout());
this.add("North", startButton);
this.add("Center", tArea);
this.add("South",clearButton);
}
}
- duplicates
-
JDK-4061822 Call JTextArea.append(String) then resize the window causes IllegalArgumentExcep
-
- Resolved
-