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

JTextArea does not have a border, but JTextField does.

XMLWordPrintable

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

      The code below needs the setBorder() method invocation on JTextArea.
      But JTextFields do ont need it.

      - eduardo

      // JTextComponent comes with a border but JTextArea does not.

      import com.sun.java.swing.*;
      import com.sun.java.swing.border.LineBorder;

      public class Test extends JPanel {

          public static JFrame frame;
          public static JTextArea t;

          public static void main(String args[]) {
      frame = new JFrame("Short");

      Box topBox = Box.createVerticalBox();

      Box box = Box.createHorizontalBox();
      box.add(new JTextField("one", 10));
      box.add(t = new JTextArea("two", 1, 10));
      t.setBorder(LineBorder.createGrayLineBorder());
      topBox.add(box);


      frame.getContentPane().add("Center", topBox);
      frame.pack();
      frame.show();
          }
      }

            tprinzing Tim Prinzing (Inactive)
            epelegrisunw Eduardo Pelegrillopart (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: