将内容放入选项卡式窗格中时出现问题
我需要将复选框放在选项卡式窗格内,但它们总是像这样在外面 替代文本 http://img340.imageshack.us/img340/3786/87088242.jpg< /a>
我想将谋杀复选框放在“输入”选项卡中。这就是我的代码中的内容
import model.*;
import java.awt.*;
import javax.swing.*;
public class Panel extends JPanel
{
JPanel panel = new JPanel();
public Panel(Prison prison)
{
setup();
build(prison);
}
private void setup()
{
setBorder(BorderFactory.createLineBorder(Color.blue));
setLayout(new GridLayout(1, 1));
}
private void build(Prison prison)
{
JTabbedPane tab = new JTabbedPane();
tab.addTab("Input", null, null, "Input");
JCheckBox crime = new JCheckBox("murder");
add(crime);
tab.addTab("Display", null, null, "Display");
add(tab);
}
}
我该如何解决这个问题?
I need to put check boxes inside tabbed panes, but they are always on the outside like this
alt text http://img340.imageshack.us/img340/3786/87088242.jpg
I want to put the murder check box inside the Input tab. This is what I have in my code
import model.*;
import java.awt.*;
import javax.swing.*;
public class Panel extends JPanel
{
JPanel panel = new JPanel();
public Panel(Prison prison)
{
setup();
build(prison);
}
private void setup()
{
setBorder(BorderFactory.createLineBorder(Color.blue));
setLayout(new GridLayout(1, 1));
}
private void build(Prison prison)
{
JTabbedPane tab = new JTabbedPane();
tab.addTab("Input", null, null, "Input");
JCheckBox crime = new JCheckBox("murder");
add(crime);
tab.addTab("Display", null, null, "Display");
add(tab);
}
}
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建一个带有您想要的按钮的面板,如下所示。
这应该将按钮放在选项卡中。
You need to create a panel with the button that you want like this.
That should put the button in the tabpane.