首先我会告诉你它是怎么回事:
应该是这样的(请参阅下面我评论中的链接):
标签必须向上,并且 TabPane 必须在所有方向上用边距填充屏幕的其余部分。
这是使用 GridBagLayout 进行布局的代码:
// Layout --begin--
this.mainPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
// Layout:headLineLabel --begin--
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipadx = 0;
gbc.ipady = 0;
gbc.insets = new Insets(0, 10, 0, 0);
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
this.mainPanel.add(this.headLineLabel, gbc);
// Layout:headLineLabel --end--
// Layout:FestplattenreinigerGraphicalUserInterfaceTabbedPane --begin--
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.ipadx = 0;
gbc.ipady = 0;
gbc.insets = new Insets(10, 10, 10, 10);
gbc.anchor = GridBagConstraints.CENTER;
this.mainPanel.add(new FestplattenreinigerGraphicalUserInterfaceTabbedPane(), gbc);
// Layout:FestplattenreinigerGraphicalUserInterfaceTabbedPane --end--
// Layout --end--
你需要知道的事情:
- FestplattenreinigerGraphicalUserInterfaceTabbedPane 扩展了 JTabbedPane。
- 我尝试指定所有约束(即使使用它们的默认值)来练习。
- 如果我表扬主播,布局仍然是这样。
这件事有什么问题?
非常感谢!(对不起,我不能直接发布图片+只有 1 个链接,因为我是新人-.-)