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

[from LICENSEE]scrollbar in JTextArea doesn't appear even if using JScrollPane.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.1.5
    • 1.1.4
    • client-libs
    • 1.1.5
    • sparc
    • solaris_2.5.1



      Name: paC48320 Date: 10/28/97


      I am a licensee(Oki Electric Industry Co., Ltd.).

      This bug appears in Swing0.5.1 on JDK 1.1.4,5D, 1.2Q.
      As followin code, scrollbar of JTextArea doesn't appear
      even if I use JScrollPane.

      If I use a construct JTextArea(int, int),
      this bug appears.
      If I use a construct JTextArea() or JTextArea(String),
      this bug doesn't appear.
      I think JTextArea which has row/column data can not
      work with JScrollPane.

      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;
      //import java.swing.*;

      public class JTextAreaTest2 {
          public static void main(String args[]) {
              Frame frame = new Frame("JTextArea Test2");
              frame.setLayout(new FlowLayout());
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });

              MenuBar menuBar = new MenuBar();
              Menu menu = new Menu("File");
              MenuItem quitMenuItem = new MenuItem("Quit");
              quitMenuItem.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      System.exit(0);
                  }
              });
              menu.add(quitMenuItem);
              menuBar.add(menu);
              frame.setMenuBar(menuBar);
              JPanel panel = new JPanel(new BorderLayout());
              panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);

              JTextArea textArea = new JTextArea(10,10);
              //JTextArea textArea = new JTextArea();
              textArea.append("This is\na JTextArea.\n");
              textArea.append("But it\ncannot scroll.\n");
              textArea.append("Please type more until scroll.\n")
              JScrollPane scroller = new JScrollPane() {
                  public Dimension getPreferredSize() {
                      return new Dimension(300,200);
                  }
                  public float getAlignmentX() {
                      return LEFT_ALIGNMENT;
                  }
              };
              scroller.getViewport().add(textArea);
              textArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
              panel.add("Center", scroller);
              textArea.setForeground(Color.black);
              textArea.setBackground(Color.white);

              //panel.add(textArea);
              frame.add(panel);
              frame.pack();
              frame.setVisible(true);
          }
      }
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: