Java examples for Swing:JPanel
pad JPanel
//package com.java2s; import java.awt.BorderLayout; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; public class Main { public static JPanel pad(JComponent component, int top, int left, int bottom, int right) { javax.swing.JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right));/*from ww w .j a va 2 s . c o m*/ panel.add(component, BorderLayout.CENTER); return panel; } }