I'm trying to get a JTabbedPane
where all tabs (the actual tabs, not the components) have the same width (either the minimum width needed for the widest label or a constant width).
I've tried to override BasicTabbedPaneUI.getTabBounds(int tabIndex, Rectangle dest)
, but apparently this method isn't used by the painting methods of BasicTabbedPaneUI
, instead it uses a rects array to determine the tabs size.
My next approach would be to override JTabbedPane.insertTab(String title, Icon icon, Component component, String tip, int index)
and setting the preferred size of the label component, but this doesn't seem very elegant and I'm not even sure it would work at all.
Is there a way to achieve this?