我想创建一个 JTabbedPane
,但我想手动创建标题,我创建了一个 JPanel
和 JLabel
我把我的图标
和背景颜色,但我不知道如何将其添加到选项卡式 Pane 中。
选项卡式 Pane 有 4 个面板:
JPanel header = new JPanel();
header.setSize(100, 50);
header.setBackground(Color.red);
JLabel icon_Label = new JLabel(Icon);
icon_Label.setText("header 1");
jTabbedPane1.getComponentAt(1).*************?!
最佳答案
我找到了
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
JLabel title = new JLabel("OK");
title.setForeground(Color.RED);
title.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/icons8-boîte-pleine-64.png")));
title.setText("GESTION A");
panel.add(title);
jTabbedPane1.setTabComponentAt(2, panel);
关于java - 使用 JPanel 和 JLabel 手动创建 JTabbedPane 的选项卡标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59809909/