views:

30

answers:

3

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?

+1  A: 
  • 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
Thanks so much!
Gnarly
+1  A: 

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
Oh hey, that worked - thanks!
Gnarly
no worries, saves you having to subclass the UI
objects
+1  A: 

I just found a better way:

component.setFocusable(false);
Gnarly
good idea, that works because the dotted lines are for the selected *and* focussed tab (not just the selected one)
objects