我想把三个按钮竖过来排,并且按钮能自动适应panel的尺寸,用GridLayout,设置column为1,但执行结果仍然是横着排,为什么啊?import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class test{
public static void main(String[] args){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
GridLayout panelLayout = new GridLayout();
panelLayout.setColumns(1);
panel.setLayout(panelLayout);
panel.add(new JButton("ddf222"));
panel.add(new JButton("ddd"));
panel.add(new JButton("ddd"));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
}