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?

priya465
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("java2s.com");
   
    JPanel panel  = new JPanel();
    panel.add(label);    
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

   
    JOptionPane.showMessageDialog(null, panel);

  }
}