I’m having a JTabbedPane (with horizontal tabs on the top) in a JPanel, and I want the tabs of this JTabbedPane to fit the whole width of the JPanel, so that if there’s only one tab, the tab would fill the whole width; when there are two tabs, each tab would fill excactly the half, and so on.
Using a custom JComponent as a the title of the tabs and setting the PreferredSize there isn’t a solution since it seems that JTabbedPanel puts some sort of border around the title-components.
Is there any easier solution than extending and/or rewriting part/all of JTabbedPane?
(Maybe I should add that when I’m talking about tabs, I refer to these navigational components you can click on to switch the component shown, and not the components themselves.)
Test this code :