Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.JButton;

import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;

public class Main {
    /**
     * 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);
        }
    }
}