Setting the margin of a JButton

Use the method setMargin and specify an Insets object with (bottom, left, right, top) margins.

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
   JList list; 
   public Main() {
      getContentPane().setLayout(new FlowLayout());
      final JButton button = new JButton("OK!");
      button.setMargin(new Insets(100, 100, 100, 100));
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
      setSize(400, 400);
   public static void main(String[] args) {
      (new Main()).show();