Here you can find the source of fixButtonUI(AbstractButton button)
public static void fixButtonUI(AbstractButton button)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.AbstractButton; import javax.swing.plaf.basic.BasicButtonListener; public class Main { /**//from ww w . j a va2 s .c om * Ensures that focus will be really painted if button is focused and fixes * using custom border for JDK 1.5 & XP LaF */ public static void fixButtonUI(AbstractButton button) { // JButton if (button.getUI() instanceof com.sun.java.swing.plaf.windows.WindowsButtonUI) { button.setUI(new com.sun.java.swing.plaf.windows.WindowsButtonUI() { protected BasicButtonListener createButtonListener(AbstractButton b) { return new BasicButtonListener(b); // Fix for Issue 71546 } protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { int width = b.getWidth(); int height = b.getHeight(); g.setColor(getFocusColor()); javax.swing.plaf.basic.BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, width - dashedRectGapWidth, height - dashedRectGapHeight); } }); } // JToggleButton else if (button.getUI() instanceof com.sun.java.swing.plaf.windows.WindowsToggleButtonUI) { button.setUI(new com.sun.java.swing.plaf.windows.WindowsToggleButtonUI() { protected BasicButtonListener createButtonListener(AbstractButton b) { return new BasicButtonListener(b); // Fix for Issue 71546 } protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { int width = b.getWidth(); int height = b.getHeight(); g.setColor(getFocusColor()); javax.swing.plaf.basic.BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, width - dashedRectGapWidth, height - dashedRectGapHeight); } }); } } }