Duplicate :
|
|
Relates :
|
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(); } }