Java tutorial
//package com.java2s; import javax.swing.AbstractButton; import javax.swing.LookAndFeel; import javax.swing.UIManager; public class Main { /** * With certain look and feels, namely windows with XP style, the focus of a toolbar button is already indicated (border changes) and the focus indicator should not be drawn: this fixes the visual rendering. * @param toolBarButton the tool bar button for which to adjust the focus state. */ public static void adjustToolbarButtonFocus(AbstractButton toolBarButton) { LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); if (lookAndFeel.isNativeLookAndFeel() && System.getProperty("os.name").startsWith("Windows") && !Boolean.parseBoolean(System.getProperty("swing.noxp")) && !lookAndFeel.getClass().getName().endsWith("WindowsClassicLookAndFeel")) { toolBarButton.setFocusPainted(false); } } }