List of usage examples for javax.swing.plaf.metal MetalTabbedPaneUI MetalTabbedPaneUI
MetalTabbedPaneUI
From source file:Main.java
public static void main(String[] args) { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setUI(new MetalTabbedPaneUI() { @Override// w w w .j ava2s .co m protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics); int extra = tabIndex * 50; return width + extra; } }); tabbedPane.addTab("JTable", new JScrollPane(new JTable(5, 5))); tabbedPane.addTab("JTree", new JScrollPane(new JTree())); tabbedPane.addTab("JSplitPane", new JSplitPane()); JPanel p = new JPanel(); p.add(tabbedPane); JFrame frame = new JFrame(); frame.setContentPane(p); frame.pack(); frame.setVisible(true); }