大哥大姐们帮个忙,帮我解决下
--------------------配置: <默认> --------------------
E:\java\Exam5_20.java:11: myMenuFrame 不是抽象的,并且未覆盖 java.awt.event.ItemListener 中的抽象方法 itemStateChanged(java.awt.event.ItemEvent)
class myMenuFrame extends Frame implements ActionListener ,ItemListener
^
1 错误
以下是代码,怎么会出现上面的错误呢,大哥大姐们帮个忙,帮我解决下
import java.awt.*;
import java.awt.event.*;
public class Exam5_20
{
public static void main(String args[])
{
myMenuFrame myMenu=new myMenuFrame();
myMenu.setVisible(true);
}
}
class myMenuFrame extends Frame implements ActionListener ,ItemListener
{
TextField text;
PopupMenu popM;
Button but;
public myMenuFrame()
{
super( "我制做的窗口 ");
setLayout(new BorderLayout());
setSize(300,200);
but=new Button( "弹出菜单按扭 ");
add( "North ",but);
this.add(but);
but.addActionListener(this);
MenuBar myB=new MenuBar();
setMenuBar(myB);
Menu m1=new Menu( "wenjian ");
MenuItem m11=new MenuItem( "dakai ");
MenuItem m12=new MenuItem( "baocun ");
MenuShortcut sc1=new MenuShortcut(KeyEvent.VK_0);
MenuShortcut sc2=new MenuShortcut(KeyEvent.VK_E);
m11.setShortcut(sc1);
m12.setShortcut(sc2);
m1.add(m11);
m1.add(m12);
m1.addSeparator();
MenuItem m13=new MenuItem( "tuichu ",new MenuShortcut(KeyEvent.VK_X));
m1.add(m13);
m1.addActionListener(this);
myB.add(m1);
popM=new PopupMenu();
MenuItem p1=new MenuItem( "fuzhi ");
p1.addActionListener(this);
popM.add(p1);
MenuItem p2=new MenuItem( "jianqie ");
p2.addActionListener(this);
popM.add(p2);
popM.addSeparator();
MenuItem p3=new MenuItem( "zhantie ");
p3.addActionListener(this);
popM.add(p3);
but.add(popM);
text=new TextField();
add( "South ",text);}
public void itemStateChanger(ItemEvent e)
{
text.setText( "zhuangtaigaibian ");
}
public void actionPerformed(ActionEvent e)
{
text.setText(e.getActionCommand());
if(e.getActionCommand()== "弹出菜单按扭 ")
popM.show(but ,50,70);
if(e.getActionCommand()== "tuichu ")
System.exit(0);
}
}
------解决方案--------------------呵呵 具体的我也不清楚
ItemListener 这个也是事件监听你为什么还要再次实现呢!!
你把它去掉再看看
------解决方案--------------------我实现了一下,就是你把ItemListener引入,而没有实现他。
所以就报了错