How to add an EmptyBorder to a JPanel?

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to add an EmptyBorder to a JPanel?

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Main {
  public static void main(String[] args) throws Exception {
    JLabel label = new JLabel("");
    JPanel panel  = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JOptionPane.showMessageDialog(null, panel);