简体   繁体   English

Java多按钮大小问题

[英]Java multiple button size issue

I'm making a simple hobby piece that simply contains two buttons. 我正在做一个简单的爱好片,它只包含两个按钮。 When I try to set the size only one button, the work button, is set. 当我尝试设置大小只有一个按钮时,设置工作按钮。 This is true even if I comment out the play button code. 即使我注释掉播放按钮代码也是如此。

Here is the button creation code: 这是按钮创建代码:

Container content = frame.getContentPane();
JButton workBtn = new JButton("Work");
JButton playBtn = new JButton("Play");
workBtn.setSize(100, 100);
playBtn.setSize(100, 100);
workBtn.setVisible(true);
playBtn.setVisible(true);
content.add(workBtn);
content.add(playBtn);

I'm guessing it's something simple but I just can't see what or find that out. 我猜这是简单的事情,但我无法看到或发现了什么。

JFrame contentPanes use BorderLayout by default. JFrame contentPanes默认使用BorderLayout。 Read up on the layout managers to learn how to best use them to your advantage. 阅读布局管理器,了解如何最好地利用它们。 You can find the link here . 你可以在这里找到链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM