Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set size of tab in JTabbedPane

Is there any way to change size of tab in JTabbedPane? I mean not all panel but only the small tab that user has to click to see what is under it.

like image 825
Bulit Avatar asked Jan 29 '12 11:01

Bulit


People also ask

How do I add a tab to JTabbedPane?

To create a tabbed pane, instantiate JTabbedPane , create the components you wish it to display, and then add the components to the tabbed pane using the addTab method.

How do you switch tabs in JTabbedPane by clicking a button?

its very simple: use the code below: JTabbedpane. setSelectedIndex();

What is displayed by JTabbedPane?

A JTabbedPane contains a tab that can have a tool tip and a mnemonic, and it can display both text and an image. The shape of a tab and the way in which the selected tab is displayed varies by Look and Feel.


1 Answers

this is 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 component in same sizes (called in main method)

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

like image 104
Harsha Sampath Avatar answered Oct 21 '22 06:10

Harsha Sampath