Java Swing:JPanel添加边框

一、JPanel添加不同边框的效果图如下所示

Java Swing:JPanel添加边框

二、 不同边框样式的代码实现

 JPanel jpanel = new JPanel();

 jpanel.setBorder(BorderFactory.你需要的样式);

 BorderFactory.createLineBorder(Color.red, 3)        //线边框  

 BorderFactory.createEtchedBorder()                 //蚀刻边框  

 BorderFactory.createRaisedBevelBorder()            //斜面边框(凸)  

 BorderFactory.createLoweredBevelBorder()           //斜面边框(凹)  

 BorderFactory.createTitledBorder("标题")          //标题边框左  

 BorderFactory.createTitledBorder("标题")          //标题边框右
setTitleJustification(TitledBorder.RIGHT); BorderFactory.createMatteBorder(1, 5, 1, 1, Color.yellow) //花色边框 b1 = BorderFactory.createLineBorder(Color.blue, 2); //组合边框
b2 = BorderFactory.createEtchedBorder();
BorderFactory.createCompoundBorder(b1, b2)
上一篇:[Ynoi2016]这是我自己的发明(莫队)


下一篇:debian安装后sudo命令不能用的解决方法