how to set font for a tab title in jtabbedpane

Viewed 3997

I have designed a tabbedpane which includes some tabs, is there any way to set a font for the titles of tabs? I have read this useful question however through this approach we can only set the title of border and not the title of a tab.

A simple code to explain my problem:

private  JTabbedPane tabbedPane;
private  JPanel tab1;
private  Jpanel tab2;
...
tabbedPane.insert("title1", icon1, tab1, "tip1", 0);
tabbedPane.insert("title2", icon2, tab2, "tip2", 1);

How can I change the font of "title1" or "title2" ?


Edit:

According to answer of Dear Jay Smith, I realized that this approach is more powerful, however I have some other problem, see this picture please:

enter image description here

I am create a JPanel (i.e. called myPanel) for each tab which consist of two JLabel, one for TabIcon and another for TabTitle. finally, I have writed this:

tabbedPane.setTabComponentAt(0, myPanel);

Now, what are problems:

  1. First of all, notice that I am using persian language which is a right to left, so I want to pull icon to the leftmost position and the tabTitle to the rightmost position.
  2. Second, according to the border of first tab, I want that panel fill entire space of tabHeader.
2 Answers
Related