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

JTextArea in a JScrollpane does not work properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs



      Name: el35337 Date: 05/28/98


      1. Steps to reproduce the problem
       
        1. run the attached code.
        2. in the text area, keep typing f.
        3. gradually you can see the caret position moved
           forward incorrectly.
        4. I tried the following fonts:
           dialog, SansSerif, Helvetica, TimesRoman,
           Courier, Monospaced, dialogInput, Serif
        5. for fonts "dialog","SansSerif","Serif",
           "Helvetica", it seems the caret works fine,
           but the horizontal scrollbar does not work
           properly, it shows up too eariler.

        Also you can run the SwingSetApplet in the demo
        directory. In the plain text tab, there is a
        JTextArea in JScrollPane, if you keep typing in
        the same line, you will find the scrollbar does not
        work properly.


      2. codes
      import java.awt.swing.*;
      import java.awt.event.*;
      import java.awt.*;

      public class TextAreaBug
      {
      public static void main(String[] args)
      {
      JFrame frame = new JFrame("JTextArea bug");
      frame.addWindowListener(new WindowAdapter() {
                      public void windowClosing(WindowEvent e) {
                          System.exit(0);
                      }
                  });

      JTextArea textArea = new JTextArea(10,10);
      textArea.setFont(new Font("Monospaced",Font.PLAIN,12));
      JScrollPane scrollPane=new JScrollPane(textArea);

      frame.getContentPane().add("Center", scrollPane);
             frame.setSize(200, 200);
             frame.setVisible(true);
          }
      }
      (Review ID: 32218)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: