ShowJcheckBox 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
原程序如下:
import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.ImageIcon;
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);
setVisible(true); 这里刚开始我用的的是show();后来自己看了篇文章,改为setVisible(true);
}
public void actionperformed(ActionEvent e){
if(e.getSource()==jCheckBox3){
if(jCheckBox3.isSelected()){
ImageIcon imageIcon2=new ImageIcon("d:\\java_project\\image\\previous.gif");
jCheckBox3.setSelectedIcon(imageIcon2);
}
}
if(e.getSource()==jCheckBox4){
if(jCheckBox4.isSelected()) System.out.println("系统复选框被选中。");
else System.out.println("系统权限复选框未被选中。");
}
}
public static void main (String[] args) {
ShowJcheckBox showJcheckBox1=new ShowJcheckBox();
}
}
希望各位大哥大姐帮我看看,指出错误所在,不胜感激!!!