[英]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.