Java JButton removeMargins(JButton button)

Here you can find the source of removeMargins(JButton button)

Description

Removes all extra spacing around the button so other components are layed out right next to it.

License

Open Source License

Parameter

Parameter Description
button the button to remove margins and formatting from

Declaration

public static void removeMargins(JButton button) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Insets;
import javax.swing.JButton;

public class Main {
    /**//from w  w w. java  2s  .  c om
     * 
     * Removes all extra spacing around the button so other components are layed out right next to it.
     * 
     * @param button
     *       the button to remove margins and formatting from
     */
    public static void removeMargins(JButton button) {
        button.setBorder(null);
        button.setBorderPainted(false);
        button.setMargin(new Insets(0, 0, 0, 0));
    }
}

Related

  1. orderOKCancelButtons(JButton okButton, JButton cancelButton)
  2. reduceNimbusButtonMargin(final JButton button)
  3. registerCancelButton(final JButton cancelButton)
  4. removeAllActionListeners(JButton button)
  5. removeAllListeners(JButton bouton)
  6. renderImageOnly(JButton button)
  7. setButtonNo(JButton anButton)
  8. setCancelButton(final JRootPane rp, final JButton b)
  9. setEmptyBorder(JButton button, int paddingTop, int paddingLeft, int paddingBottom, int paddingRight)