I have a tabbed pane, i want to resize the tabs...... not the entire tabbed pane and nor the panels added to it. But the tabs themselves.... more clearly what i want is...

to alter the size of the display tab1 and tab2........ how do i do this.......??
Override calculateTabWidth on your BasicTabbedPaneUI like this:
public static void main(String[] args) throws Exception {
JTabbedPane tabs = new JTabbedPane(JTabbedPane.LEFT);
tabs.setUI(new BasicTabbedPaneUI() {
@Override
protected int calculateTabWidth(
int tabPlacement, int tabIndex, FontMetrics metrics) {
return 200; // the width of the tab
}
});
tabs.add("Tab 1", new JButton());
tabs.add("Tab 2", new JButton());
JFrame frame = new JFrame("Test");
frame.add(tabs);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With