Java JButton Create makeButtonFlat(AbstractButton button)

Here you can find the source of makeButtonFlat(AbstractButton button)

Description

make Button Flat

License

Open Source License

Declaration

public static void makeButtonFlat(AbstractButton button) 

Method Source Code

//package com.java2s;

import javax.swing.AbstractButton;

import javax.swing.JToggleButton;

import javax.swing.UIDefaults;
import javax.swing.UIManager;

import javax.swing.plaf.basic.BasicBorders;
import javax.swing.plaf.basic.BasicButtonUI;

import javax.swing.plaf.basic.BasicToggleButtonUI;

public class Main {
    public static void makeButtonFlat(AbstractButton button) {
        // Override the default look and feel: use basic L&F because some L&F (esp. WinXP)
        // ignores the border property
        if (button instanceof JToggleButton) {
            button.setUI(new BasicToggleButtonUI());
        } else {/*  w  w  w.  ja v  a  2  s.  c  om*/
            button.setUI(new BasicButtonUI());
        }

        button.setRolloverEnabled(true);

        UIDefaults table = UIManager.getLookAndFeelDefaults();
        button.setBorder(new BasicBorders.RolloverButtonBorder(table.getColor("controlShadow"), //$NON-NLS-1$
                table.getColor("controlDkShadow"), //$NON-NLS-1$
                table.getColor("controlHighlight"), //$NON-NLS-1$
                table.getColor("controlLtHighlight"))); //$NON-NLS-1$
    }
}

Related

  1. getCreateButton()
  2. makeButton(Action action)
  3. makeButton(String name, ActionListener l)
  4. makeButtonActLikeLabel(JButton button)
  5. makeButtonBar(int align, Component... comps)
  6. makeButtonPanel(Vector names, ActionListener actionListener)
  7. makeIconButton(Icon icon, String tooltip)
  8. makeNavigationButton(String actionCommand, String toolTipText, String altText)
  9. makeRadioButton(String text, String actionCommand, ButtonGroup buttonGroup, boolean selected)