JAVA 相关问题 The type BRTest must implement the inherited abstract
package例题4;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;classBRTestext...
package 例题4;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class BRTest extends JFrame implements ItemListener,ActionListener
{
JTextField text=new JTextField(15);
BRTest(String s)
{
setSize(200,200);
setVisible(true);
setTitle(s);
setLayout(new FlowLayout());
JCheckBox cb1=new JCheckBox("C语言");
cb1.addItemListener(this);
add(cb1);
JCheckBox cb2=new JCheckBox("C++语言");
cb2.addItemListener(this);
add(cb2);
JCheckBox cb3=new JCheckBox("Java语言");
cb3.addItemListener(this);
add(cb3);
JRadioButton b1=new JRadioButton("鲜花");
b1.addActionListener(this);
add(b1);
JRadioButton b2=new JRadioButton("鼓掌");
b1.addActionListener(this);
add(b2);
JRadioButton b3=new JRadioButton("鸡蛋");
b1.addActionListener(this);
add(b3);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
bg.add(b3);
add(text);
validate();
}
public void itemStateChanged(ItemEvent ie){
JCheckBox cb=(JCheckBox)ie.getItem();
text.setText(cb.getText());
}
public void actionPerforemd(ActionEvent ae){
text.setText(ae.getActionCommand());}
}
public class li4 {
public static void main(String args[])
{
new BRTest("简单的复选单选框");
}
}
报错 The type BRTest must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent) 不知道为什么? 谢谢 展开
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class BRTest extends JFrame implements ItemListener,ActionListener
{
JTextField text=new JTextField(15);
BRTest(String s)
{
setSize(200,200);
setVisible(true);
setTitle(s);
setLayout(new FlowLayout());
JCheckBox cb1=new JCheckBox("C语言");
cb1.addItemListener(this);
add(cb1);
JCheckBox cb2=new JCheckBox("C++语言");
cb2.addItemListener(this);
add(cb2);
JCheckBox cb3=new JCheckBox("Java语言");
cb3.addItemListener(this);
add(cb3);
JRadioButton b1=new JRadioButton("鲜花");
b1.addActionListener(this);
add(b1);
JRadioButton b2=new JRadioButton("鼓掌");
b1.addActionListener(this);
add(b2);
JRadioButton b3=new JRadioButton("鸡蛋");
b1.addActionListener(this);
add(b3);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
bg.add(b3);
add(text);
validate();
}
public void itemStateChanged(ItemEvent ie){
JCheckBox cb=(JCheckBox)ie.getItem();
text.setText(cb.getText());
}
public void actionPerforemd(ActionEvent ae){
text.setText(ae.getActionCommand());}
}
public class li4 {
public static void main(String args[])
{
new BRTest("简单的复选单选框");
}
}
报错 The type BRTest must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent) 不知道为什么? 谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询