62,623
社区成员
发帖
与我相关
我的任务
分享
add(panel);
setLayout(new FlowLayout());
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
public class MyClass extends JFrame
{
private JPanel panel = new JPanel();
public MyClass()
{
setTitle("测试");
panel.add(new JButton("1"));
panel.add(new JButton("221"));
panel.add(new JButton("3"));
add(panel,BorderLayout.SOUTH);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new FlowLayout(FlowLayout.LEFT)); //需要在这里设置一下就可以了
setResizable(false);
setSize(400,300);
setVisible(true);
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
new MyClass();
}
}