Java JButton reduceNimbusButtonMargin(final JButton button)

Here you can find the source of reduceNimbusButtonMargin(final JButton button)

Description

Reduce the margins around the content of a button for the Nimbus look and feel

License

Open Source License

Parameter

Parameter Description
button button to alter

Declaration

public static void reduceNimbusButtonMargin(final JButton button) 

Method Source Code

//package com.java2s;
/*//  w w  w .  j  av  a 2  s  .  c o m
 * jGnash, a personal finance application
 * Copyright (C) 2001-2015 Craig Cavanaugh
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.UIDefaults;

public class Main {
    /**
     * Reduce the margins around the content of a button for the Nimbus look and feel
     * 
     * @param button button to alter
     */
    public static void reduceNimbusButtonMargin(final JButton button) {
        UIDefaults buttonDefaults = new UIDefaults();
        buttonDefaults.put("Button.contentMargins", new Insets(6, 6, 6, 6));

        button.putClientProperty("Nimbus.Overrides", buttonDefaults);
        button.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.FALSE);
    }
}

Related

  1. initHelpButton(final JButton buttonHelp)
  2. nombreImg(JButton boton)
  3. normalizeComponentDimension(JComponent[] jButtonList)
  4. nullifyButtonUI(final JButton button)
  5. orderOKCancelButtons(JButton okButton, JButton cancelButton)
  6. registerCancelButton(final JButton cancelButton)
  7. removeAllActionListeners(JButton button)
  8. removeAllListeners(JButton bouton)
  9. removeMargins(JButton button)