Set tab size in JTabbedPane

Can I resize tabs in JTabbedPane ? I do not mean all the panels, but only a small tab that the user must click to see what is below it.

+6
source share
3 answers

You can create your own TabbedPaneUI , but it can be simpler if you just use JTabbedPane#setTabComponentAt and use a larger component to display the tab title

+6
source

it worked for me.

  JLabel lab = new JLabel(); lab.setPreferredSize(new Dimension(200, 30)); jTabbedPane1.setTabComponentAt(0, lab); // tab index, jLabel 

or try this change to all tab components in the same size (called in the main method)

UIManager.getLookAndFeelDefaults().put("TabbedPane:TabbedPaneTab.contentMargins", new Insets(10, 100, 0, 0));

+6
source

To create a custom tabbedPane, I recommend checking out the Oracle tutorial . You must create your own panel, then you can change the component that displays the title. Finally, you use setTabComponentAt to place your panel in the panel.

+3
source

Source: https://habr.com/ru/post/907148/


All Articles