As you can see from the image below, the Java text is horizontal. What I would like to do is get a vertical orientation of the JTabbedPane Titles.
While googling, I found that the only way is to add extra library. But I was wondering if this can be done without any extra library?
I would like for Title1 and Title2 to be vertically oriented and not horizontally
You can use a JLabel
with a custom LabelUI
as described in this answer, it gives the result I expected:
JTabbedPane tabPane = new JTabbedPane(JTabbedPane.LEFT);
// Add tabs with no text
tabPane.addTab(null, component1);
tabPane.addTab(null, component2);
// Create vertical labels to render tab titles
JLabel labTab1 = new JLabel("Tab #1");
labTab1.setUI(new VerticalLabelUI(false)); // true/false to make it upwards/downwards
tabPane.setTabComponentAt(0, labTab1); // For component1
JLabel labTab2 = new JLabel("Tab #2");
labTab2.setUI(new VerticalLabelUI(false));
tabPane.setTabComponentAt(1, labTab2); // For component2