给 JPanel 设置 padding

在用 swing 写界面,想给 JPanel 容器设置缩进,效果类似 CSS 盒子中的 padding 属性。 使用 setBorder 可以实现。以下 copy 自 StackOverFlow: Set an EmptyBorder around your JPanel. Example: JPanel p =new JPanel(); p.setBorder(new EmptyBorder(1