📄 showjcheckbox.java
字号:
import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.ImageIcon;
//import javax.swing.UIManager;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class ShowJCheckBox extends JFrame implements ActionListener{
FlowLayout flowLayout1=new FlowLayout();
JCheckBox jCheckBox1=new JCheckBox("修改数据权限");
JCheckBox jCheckBox2=new JCheckBox("遍历数据权限",true);
ImageIcon imageIcon1=new ImageIcon("d:\\java_project\\image\\next.gif");
JCheckBox jCheckBox3=new JCheckBox("录入数据权限",imageIcon1);
JCheckBox jCheckBox4=new JCheckBox();
ShowJCheckBox(){
super("复选框示例");
setSize(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(jCheckBox1);
this.getContentPane().add(jCheckBox2);
this.getContentPane().add(jCheckBox3);
jCheckBox4.setText("系统权限");
this.getContentPane().add(jCheckBox4);
jCheckBox4.addActionListener(this);
jCheckBox3.addActionListener(this);
show();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==jCheckBox4){
if(jCheckBox4.isSelected()) System.out.println("系统权限复选框被选中.");
else System.out.println("系统权限复选框未被选中.");
}
if(e.getSource()==jCheckBox3){
if(jCheckBox3.isSelected()){
ImageIcon imageIcon2=new ImageIcon("d:\\java_project\\image\\previous.gif");
jCheckBox3.setSelectedIcon(imageIcon2);
}
}
}
public static void main(String[] args){
//try{
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//}catch(Exception e){}
ShowJCheckBox showJCheckBox1=new ShowJCheckBox();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -