我有一个 JPanel,在里面我使用这样的 GridLayout:
JPanel panel = new JPanel(new GridLayout(0, 1, 0, 0));
JPanel p1 = new JPanel(new FlowLayout());
JLabel label = new JLabel("SOMETHING");
JTextField tf = new JTextField(30);
JPanel p2 = new JPanel();
JTextArea txt = new JTextArea(6, 30);
JScrollPane sp = new JScrollPane(txt);
p1.add(label);
p1.add(tf);
p2.add(sp);
panel.add(p1);
panel.add(p2);
不幸的是,JTextArea 和上面的元素之间的空间非常大。我能做些什么来启动 JTextArea?
http://img20.imageshack.us/img20/1086/screenshot1412201213550.png