简体   繁体   English

摆动创建选项卡式窗格

[英]Swing creating a tabbed pane

I am using Swing and trying to create another tabbed pane for my GUI. 我正在使用Swing并尝试为GUI创建另一个选项卡式窗格。 I searched online and found examples, but when I try it out the new tabbed pane is not created. 我在线搜索并找到了示例,但是当我尝试时,不会创建新的选项卡式窗格。 I pasted my tabbed pane code below, thank you 我在下面粘贴了选项卡式窗格代码,谢谢

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());

How to make a tabbed pane: 如何制作选项卡式窗格:

Declare The tabs: 声明选项卡:

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

Declare the top Panel 声明顶部面板

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

Add The top Panel to JFrame 将顶部面板添加到JFrame

    trFrame.add(topPanel);

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

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