How would I go about making the length of the tabs automatically resize based on how much room is left in that row of tabs.
Picture:

As you can see the tab’s width is based off the text in the tab.
If you need me to explain what I want better then just ask me because I don’t know if I made it clear enough.
You can use a custom component and set it’s preferred size. For example, in
ButtonTabComponentofTabComponentsDemo:You have to choose an appropriate dimension based on other aspects of your layout, so it won’t be automatic.
The size of the
JTabbedPaneis a function of the dimensions andLayoutManagerof theContainerto which it has been added. In the example cited, the default layout of the frame’s content pane isBorderLayout, andadd(pane)adds it to the center by default.To accomplish your goal, I see two approaches:
Divide the current width of the enclosing
Containeramong the existing tabs and repaint the tabbed pane, as shown in this example.Develop your own implementation of
TabbedPaneUIand interpretSCROLL_TAB_LAYOUTaccordingly.