java BorderFrame.java
作者:互联网
简介边框的设置
简单
lowerd 低于设计的平面
Riased 高于设计的平面
Etched 嵌入
Line 线条形式
Matte 粗线条似乎?
Empty 没有边框
code
/*
* @Author: your name
* @Date: 2020-11-04 19:08:11
* @LastEditTime: 2020-11-04 19:25:16
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /java/calcu/BorderFrame.java
*/
package calcu;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class BorderFrame extends JFrame {
private JPanel demoPanel;
private JPanel buttonPanel;
private ButtonGroup group;
public static void main(String[] args) {
BorderFrame t = new BorderFrame();
t.setTitle("ImageTest");
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
t.setVisible(true);
}
public BorderFrame(){
demoPanel = new JPanel();
buttonPanel = new JPanel();
group = new ButtonGroup();
addRadioButton("Lower bevel", BorderFactory.createLoweredBevelBorder());
addRadioButton("Rasied bevel", BorderFactory.createRaisedBevelBorder());
addRadioButton("Etched", BorderFactory.createEtchedBorder());
addRadioButton("Line", BorderFactory.createLineBorder(Color.BLUE));
addRadioButton("Matte", BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE));
addRadioButton("Empty", BorderFactory.createEmptyBorder());
Border etched = BorderFactory.createEtchedBorder(); // 可以实现继承显示
Border titled = BorderFactory.createTitledBorder(etched, "Border types");
buttonPanel.setBorder(titled);
setLayout(new GridLayout(2,1));
add(buttonPanel);
add(demoPanel);
pack();
}
public void addRadioButton(String buttonName, Border b) {
JRadioButton button = new JRadioButton(buttonName);
button.addActionListener(event -> demoPanel.setBorder(b));
group.add(button);
buttonPanel.add(button);
}
}
标签:java,buttonPanel,BorderFactory,new,addRadioButton,BorderFrame 来源: https://www.cnblogs.com/eat-too-much/p/13927675.html