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

JTextArea painting problems

XMLWordPrintable

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

      This problem may be related to the previous bug 4424699 filed by me. It happens in Solaris Sparc 2.7 and does not happen in Windows.

      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b55)
      Java HotSpot(TM) Client VM (build 1.4beta-B55, mixed mode)

      Found 2 interesting things happening in JTextArea. Run the example pasted below.
      Issue 1:
      --------
      Scroll from top to bottom of the document seen on the JTextArea using arrow keys only. Once at the bottom of the document, scroll to top again using arrow keys. Once reaching the top, the cursor does not stop, instead it keeps on painting the topline agaia and again till you relase the up arrow button.

      Issue 2:
      --------
      Start typing something in the JTextArea pressing "Return" key often. After a few such line entries, (you should be at or near the horizontal scrollbar) you can see the ScrollPane's horizontal bar pops up and one can see two horizontal scrollbars. At one instance, I lost the horizontal scrollbar and only vertical scrollbar was visible.

      Code to reproduce:
      -----------------
      import java.io.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      class TextAreaExample
                      extends JFrame
      {
              public TextAreaExample()
              {
                      setTitle( "Text Area Application" );
                      setSize( 310, 230 );
                      setBackground( Color.gray );
                      getContentPane().setLayout( new BorderLayout() );

                      JPanel topPanel = new JPanel();
                      topPanel.setLayout( new BorderLayout() );
                      getContentPane().add( topPanel, BorderLayout.CENTER );

              // Create a text area
                      JTextArea area = new JTextArea();

              JScrollPane scrollPane = new JScrollPane();
              scrollPane.getViewport().add( area );
                      scrollPane.setBounds( 10, 10, 280, 180 );
                      topPanel.add( scrollPane, BorderLayout.CENTER );

                      // Load a file into the text area, catching any exceptions
                      try {
                          FileReader fileStream = new FileReader( "TextAreaExample.java" );
                      area.read( fileStream, "TextAreaExample.java" );
              }
              catch( FileNotFoundException e )
              {
                  System.out.println( "File not found" );
              }
              catch( IOException e )
              {
                  System.out.println( "IOException occurred" );
              }
              }

              public static void main( String args[] )
              {
                      // Create an instance of the test application
                      TextAreaExample mainFrame = new TextAreaExample();
                      mainFrame.setVisible( true );
              }
      }

            svioletsunw Scott Violet (Inactive)
            sramansunw Sridhar Raman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: