2

How do you remove the dotted line around the currently selected tab on a JTabbedPane.

For example:

alt text

See the dotted line around it?

3 Answers3

7

I just found a better way:

component.setFocusable(false);
  • good idea, that works because the dotted lines are for the selected *and* focussed tab (not just the selected one) – objects Jul 18 '10 at 12:03
5

try setting the focus colour

UIManager.put("TabbedPane.focus", new Color(0, 0, 0, 0));

or set it to the same colour as the background

objects
  • 8,637
  • 4
  • 30
  • 38
3
  • This is painted by the current Look and Feel.
  • I believe what is needed will depend on the LnF you're using.

  • You'll want to create a custom TabbedPaneUI class, probably overriding the one in your chosen L&F. You might be overriding javax.swing.plaf.basic.BasicTabbedPaneUI.

  • override paintFocusIndicator, and make it an empty method.
  • You will need to create an instance of this class, then call myTabbedPane.setUI(myTabbedPaneUI)
Sanjay Manohar
  • 6,920
  • 3
  • 35
  • 58
  • this is very useful because UI delegates are a poorly discussed topic, but they are not necessarily difficult to use. – AgostinoX Oct 21 '11 at 10:49