JTabbedPane настраивает внешний вид вкладок

Я хочу настроить внешний вид вкладок в JTabbedPane.
Я хочу начать с самого простого и понятного поведения: без границ, сплошным цветом.
Проблема в том, что не простое поведение все еще остается: вкладки немного перекрывают поля.

enter image description here

Вы видите, что поскольку вторая вкладка выделена, она "выдвигается на передний план". Это достигается за счет небольшого перекрытия полей. Есть ли способ (не хитрый) отключить это поведение?

простой, проверяемый (просто исправьте импорт) код:

public class TabbedPane_LookStudy extends JFrame{

public static void main(String [] args) throws UnsupportedLookAndFeelException {
    UIManager.setLookAndFeel(new NimbusLookAndFeel());
    new TabbedPane_LookStudy().setVisible(true);
}

public TabbedPane_LookStudy() {
    JTabbedPane tp = new JTabbedPane();
    tp.setUI(new MyTabbedPaneUI());
    add(tp);

    tp.addTab("first",new JPanel());
    tp.addTab("second", new JPanel());
    tp.addTab("third", new JPanel());

    setPreferredSize(new Dimension(180,100));
    pack();
}

public static class MyTabbedPaneUI extends javax.swing.plaf.basic.BasicTabbedPaneUI {

    @Override
    protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, 
               int tabIndex, Rectangle iconRect, Rectangle textRect) {
        Color savedColor = g.getColor();
        g.setColor(Color.PINK);
        g.fillRect(rects[tabIndex].x, rects[tabIndex].y, 
               rects[tabIndex].width, rects[tabIndex].height);
        g.setColor(Color.BLUE);
        g.drawRect(rects[tabIndex].x, rects[tabIndex].y, 
               rects[tabIndex].width, rects[tabIndex].height);
        g.setColor(savedColor);
    }
 }

}

8
задан AgostinoX 22 October 2011 в 15:36
поделиться