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

TextArea.preferredSize(rows, cols) doesn't allocate extra room for scrollbars

    XMLWordPrintable

Details

    • 1.0.2
    • sparc
    • solaris_2.4, solaris_2.5
    • Not verified

    Description

      TextArea.preferredSize(int rows, int cols) returns a result that doesn't take the size of the TextArea's scrollbars into account. Hence reshaping to the returned size gives you a TextArea with room for fractionally fewer rows and columns than you asked for.

      The description field as copied from bug report 1236911 follows:

      >From: Garth Allen Dickie <###@###.###>
      This does not look like form output to me.


      Hi, I am using the JDK beta 2 for Solaris 2.4. When I
      construct a TextArea component with rows=n, only n-1 rows
      of text are visible. If I create TextArea component with
      rows=1, then only part of the row is visible.

      Regards,
      Garth A. Dickie
      _________
      <Jim Hagen> I've constructed the example below to demostrate this.
      mport java.awt.*;

      public class T3169 extends Frame
        {
        Panel panel;
        TextArea t;

        int windowWidth = 200;
        int windowHeight = 150;

        public T3169(String args[])
          {
          super("Bug Report 3169");

          panel = new Panel();
          t = new TextArea("This Text is not fully displayed", 1,15);
          panel.add(t);
          add("South", panel);

          resize(windowWidth, windowHeight);
          pack();
          show();
          }


        public static void main(String args[])
          {
          new T3169(args);
          }
        }

      The description field as copied from bug report 1235284 follows:

      To followup on this bug, please contact ###@###.###
      This code example adds 2 fields and a TextArea to a Panel. Not exactly what I'd do but it should work. The problem is relatively minor- unless you're trying to type on the last line of the TextArea, since the last line is not visible and the second-to-last is only partly visible.
       
      This one comes from a customer.
       _____Begin Customer Data_____
      What happens: In the attached program, a TextArea is added to a panel and
      the panel is added to the frame. A List is added below the panel. Note
      that the bottom anchor of the TextArea is obscured by the List; changing
      the size of the visible part of the list has no effect.

      Thanks for looking into this!

      Robert Uomini
      >From: ###@###.### (Robert Uomini)
      _____End Customer Data_____
      In the code below I have removed the List for clarity- the bottom of the TextArea is still not visible even without any other objects added to the panel after it.
      _____Begin test code_____

      import java.awt.*;

      public class BugReportv extends Frame
        {
        Panel panel1;

        TextArea textarea;

        List list;

        Label label1;
        Label label2;

        TextField text1;
        TextField text2;

        int windowWidth = 450;
        int windowHeight = 700;

        public BugReportv(String args[])
          {
          super("Bug Reportv.JimmiChangedME");

          panel1 = new Panel();

          label1 = new Label("Label1:");
          label1.setFont(new Font("Courier", Font.BOLD, 14));
          panel1.add(label1);

          text1 = new TextField("text1", 32);
          panel1.add(text1);

          label2 = new Label("Label2:");
          label2.setFont(new Font("Courier", Font.BOLD, 14));
          panel1.add(label2);

          text2 = new TextField("text2", 32);
          panel1.add(text2);

          textarea = new TextArea(30, 50);
          panel1.add(textarea);
          add("Center", panel1);

          //list = new List(10, false);
          //add("South", list);

          resize(windowWidth, windowHeight);
          show();
          }

        public static void main(String args[])
          {
          new BugReportv(args);
          }
        }

      Attachments

        Issue Links

          Activity

            People

              duke J. Duke
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: