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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.1.4
    • Fix Version/s: 1.1.5
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: