Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4060026

JTextArea.setText( String) causes IllegalArgumentException on Solaris

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1.2
    • client-libs
    • None

      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);

        }


      }

            tprinzing Tim Prinzing (Inactive)
            pchusunw Patience Chu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: