[英]How can I set the size of JButton in an Applet?
我有一个applet,我想添加一个jbutton。 问题是按钮太大,我已经使用过setSize()方法,但仍然无法正常工作。 也许setSize的设置可能是错误的。
有人对这个问题有想法吗?
谢谢...
private JButton newGame = new JButton("New Game");
private JButton players = new JButton("Players");
private JButton quit = new JButton("Quit");
public void init()
{
Container content = getContentPane();
content.setLayout(new BorderLayout());
mainPanel = new JPanel();
getContentPane().add(mainPanel);
setVisible(true);
setSize(400, 400);
content.add(newGame);
content.add(players);
content.add(quit);
}
将JPanel添加到您的applet中,然后向其中添加JButton
树代码的概念是
JApplet(GridLayout)<-JPanel(FlowLayout)<-JButton(setSize(new Dimension(x,y)))
祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.