brian_d
brian_d

Reputation: 11385

JTabbedPane indent

When using a JTabbedPane, how do you indent the tabs?

Swing default output:

-------  ---------  ------
|  A  |  |   B   |  |  C |
------------------------------
|                            |
|                            | 
|                            |
|                            |
|                            |

Desired indented output:

   -------  ---------  ------
   |  A  |  |   B   |  |  C |
------------------------------
|                            |
|                            | 
|                            |
|                            |
|                            |

This seems simple enough, but I have not been able to find the solution. Thanks.

Upvotes: 2

Views: 586

Answers (2)

camickr
camickr

Reputation: 324108

For all tabbed panes you can use the following with the default LAF:

UIManager.put("TabbedPane.tabAreaInsets", new Insets(2, 20, 0, 6) );

See also: UIManager Defaults

For individual tabbed panes you would probably need to override the "getTabAreaInsets()" method of the BasicTabbedPaneUI class to return the above Inset.

Upvotes: 1

Etaoin
Etaoin

Reputation: 8724

If there's no way to do it with a simple JTabbedPane, you could use the following (slightly inelegant) solution:

Create your own component, consisting of a JTabbedPane and a JPanel. The JTabbedPane displays only the tabs; as far as it's concerned, each tab is empty. The JPanel (using a CardLayout) is responsible for actually displaying each tab. Add a ChangeListener to the JTabbedPane, and use it to switch between cards of the CardLayout.

Then all you have to do is lay out the JTabbedPane and the JPanel in your own component, which you can do however you like. That lets you push the tabs over to the right.

Upvotes: 0

Related Questions