Java examples for Swing:JButton
Fixes button opacity issues.
//package com.java2s; import javax.swing.JButton; import javax.swing.UIManager; import javax.swing.plaf.metal.MetalLookAndFeel; public class Main { /**/*from w w w. jav a 2s .c o m*/ * Fixes button opacity issues. * This is particularly a problem with JButton on Macintosh; * when the background color of its container is changed, * a button will appear to be sitting on a gray rectangle. * * @param button */ public static void fixButtonOpacity(JButton button) { // If the LAF isn't Metal or a derivative, setOpaque( false ) for the button if (!(UIManager.getLookAndFeel() instanceof MetalLookAndFeel)) { button.setOpaque(false); } } }