I would like to get the effect like if JTabbedPane would be turned 90 degrees counterclockwise (only tabs but not the content inside tabs). What is the best way to implement that in Java?
5 Answers
You can specify the placement in the constructor:
http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#JTabbedPane%28int%29
or in the setter:
http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#setTabPlacement%28int%29

- 37,247
- 13
- 80
- 152
In this solution:
http://oreilly.com/pub/a/mac/2002/03/22/vertical_text.html
The text was painted vertically and tried as an icon on the tab. This way you don't have to modify JTabbedPane you just use a custom Icon in the tab.
Of course you would also have to specify the tab placement to be on the Left.

- 23,473
- 9
- 54
- 76
-
1and some examples for that http://www.java2s.com/Code/Java/Swing-JFC/TabbedPane.htm + 1 – mKorbel Jun 17 '11 at 19:22
-
@mKorbel: I didn't find vertical tabs examples there. – bancer Jun 17 '11 at 19:40
-
@bancer really time convert your requirements to code that you show here, maybe is about small hack, you can Edit your original question, then we'd look at it – mKorbel Jun 17 '11 at 20:04
-
The link provided by jzd is good. The solution and implementation provided there is not ideal but is good and acceptable. – bancer Jun 17 '11 at 21:29
-
The link is dead, an archived version can be viewed here: https://web.archive.org/web/20160727035553/http://archive.oreilly.com/pub/a/mac/2002/03/22/vertical_text.html – Polyana Fontes Nov 12 '20 at 17:13
As an alternative, consider JToolBar
with orientation
set to VERTICAL
in a BorderLayout
, EAST
or WEST
. It's fairly easy rotate text in the button's Icon
.
You can try setTabPlacement(SwingConstants.LEFT)
or this component

- 5,389
- 5
- 28
- 45
-
I don't see how that link helps. Plus the tab placement would not create vertical text. – jzd Jun 17 '11 at 18:59
-
As I understood, author needs vertical tabs but horizontal text, I decided it from this @(only tabs but not the content inside tabs)@ – Sergii Zagriichuk Jun 17 '11 at 19:48
You could try and extend the tabpane class, in the overloaded paint method, get the graphics object, say g2d
is the argument of the overloaded paint method:
super(g2d.rotate(Pi/2));
as a starter

- 21
- 1