import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.border.Border; import java.awt.*; public class BorderTest { private JFrame jf = new JFrame("test border"); public void init(){ jf.setLayout(new GridLayout(2,4)); Border bb = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.RED, Color.GREEN,Color.BLUE, Color.GRAY); jf.add(getPanelWithBorder(bb, "BevelBorder")); jf.pack(); jf.setVisible(true); } public static void main(String[] args) { new BorderTest().init(); } public JPanel getPanelWithBorder(Border b, String BorderName) { var p = new JPanel(); p.add(new Label(BorderName)); p.setBorder(b); return p; } }
output: