Swing创建选项卡式窗格

时间:2016-09-01 03:54:41

标签: java swing user-interface

我正在使用Swing并尝试为我的GUI创建另一个选项卡式窗格。我在网上搜索并找到了示例,但是当我尝试它时,没有创建新的选项卡式窗格。我在下面粘贴了选项卡式窗格代码,谢谢

layout = new FormLayout("p,6dlu,p,3dlu,p,10dlu:grow", "p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,10dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu");
formBuilder = new DefaultFormBuilder(layout);

cc = new CellConstraints();
formBuilder.setBorder(Borders.DLU4_BORDER);

tab = new JTabbedPane();
tab.add("New", formBuilder.getPanel());

1 个答案:

答案 0 :(得分:0)

如何制作选项卡式窗格:

声明选项卡:

    JTabbedPane tabs = new JTabbedPane();
    Panel chat = new Panel();
    Panel vrage = new Panel();
    tabs.add("Chat", chat);
    tabs.add("Questions", vrage);

声明顶部面板

    JPanel topPanel = new JPanel();
    topPanel.add(tabs);

将顶部面板添加到JFrame

    trFrame.add(topPanel);