Java tutorial
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); } }