package stuui;import java.awt.*;
import java.awt.event.*;public class MainFrame
{
public static void main(String args[])
{
Framework mf=new Framework();
mf.setSize(300,200);
mf.setVisible(true);
}
}class Framework extends Frame implements ActionListener
{
MenuBar mf_mb;
Menu mf_file,mf_StuInfo;
MenuItem mf_exit,mf_add,mf_update,mf_del,mf_searchByID,mf_searchAll,mf_statistics; Framework()
{
super("主界面"); mf_mb=new MenuBar(); mf_file=new Menu("文件");
mf_file.setActionCommand("文件");
mf_file.addActionListener(this);
mf_exit=new MenuItem("退出");
mf_exit.setActionCommand("退出");
mf_exit.addActionListener(this);
mf_file.add(mf_exit);
mf_mb.add(mf_file); mf_StuInfo=new Menu("学生信息维护");
mf_StuInfo.setActionCommand("学生信息维护");
mf_add=new MenuItem("增加学生信息信息");
mf_add.setActionCommand("增加学生信息");
mf_add.addActionListener(this);
mf_update=new MenuItem("修改学生信息");
mf_update.setActionCommand("修改学生信息");
mf_update.addActionListener(this);
mf_del=new MenuItem("删除学生信息");
mf_del.setActionCommand("删除学生信息");
mf_del.addActionListener(this);
mf_searchByID=new MenuItem("根据学号查询学生信息");
mf_searchByID.setActionCommand("根据学号查询学生信息");
mf_searchByID.addActionListener(this);
mf_searchAll=new MenuItem("查询所有学生信息");
mf_searchAll.setActionCommand("查询所有学生信息");
mf_searchAll.addActionListener(this);
mf_statistics=new MenuItem("学生统计");
mf_statistics.setActionCommand("学生统计");
mf_statistics.addActionListener(this);
mf_StuInfo.add(mf_add);
mf_StuInfo.add(mf_update);
mf_StuInfo.add(mf_del);
mf_StuInfo.add(mf_searchByID);
mf_StuInfo.add(mf_searchAll);
mf_StuInfo.add(mf_statistics);
mf_mb.add(mf_StuInfo); public void actionPerformed(ActionEvent e)
{
}
;
}
}class addFrame extends Frame implements ActionListener
{
Label name=new Label("姓名");
Label age=new Label("年龄");
TextField input1,input2;
Button btnAdd,btnCancel; addFrame()
{
super("增加学生信息");
input1=new TextField(10);
input2=new TextField(4);
btnAdd=new Button("增加");
btnCancel=new Button("取消");
  add(name);
  add(input1);
  add(age);
  add(input2);
  add(btnAdd);
  add(btnCancel);
  setSize(300,200);
  input1.addActionListener(this);
  input2.addActionListener(this);
  btnAdd.addActionListener(this);
  btnCancel.addActionListener(this);
  show();
} public void actionPerformed(ActionEvent e)
{
}
}class updateFrame extends Frame implements ActionListener
{
Label name=new Label("姓名");
Label age=new Label("年龄");
Label inputstuID=new Label("输入学号");
TextField input1,input2,input3;
Button btnUpdate,btnCancel,btnSearch; updateFrame()
{
super("修改学生信息");
input1=new TextField(4);
input2=new TextField(10);
input3=new TextField(4);
btnUpdate=new Button("修改");
btnCancel=new Button("取消");
btnSearch=new Button("查询");
add(inputstuID);
add(input1);
add(btnSearch);
add(name);
add(input2);
add(age);
add(input3);
add(btnUpdate);
add(btnCancel);
setSize(300,200);
input1.addActionListener(this);
btnSearch.addActionListener(this);
input2.addActionListener(this);
input3.addActionListener(this);
btnUpdate.addActionListener(this);
btnCancel.addActionListener(this);
show();
}
}class delFrame extends Frame implements ActionListener
{
Label name=new Label("姓名");
Label age=new Label("年龄");
Label inputstuID=new Label("输入学号");
TextField input1,input2,input3;
Button btnDel,btnCancel,btnSearch; delFrame()
{
super("删除学生信息");
input1=new TextField(4);
input2=new TextField(10);
input3=new TextField(4);
btnUpdate=new Button("删除");
btnCancel=new Button("取消");
btnSearch=new Button("查询");
add(inputstuID);
add(input1);
add(btnSearch);
add(name);
add(input2);
add(age);
add(input3);
add(btnDel);
add(btnCancel);
setSize(300,200);
input1.addActionListener(this);
btnSearch.addActionListener(this);
input2.addActionListener(this);
input3.addActionListener(this);
btnDel.addActionListener(this);
btnCancel.addActionListener(this);
show();
}
public void actionPerformed(ActionEvent e)
{
}
}class searchByIDFrame extends Frame implements ActionListener
{
Label name=new Label("姓名");
Label age=new Label("年龄");
Label inputstuID=new Label("输入学号");
TextField input1,input2,input3;
Button btnCancel,btnSearch; searchByIDFrame()
{
super("根据学号查询学生信息");
input1=new TextField(4);
input2=new TextField(10);
input3=new TextField(4);
btnSearch=new Button("查询");
btnCancel=new Button("取消");
add(inputstuID);
add(input1);
add(name);
add(input2);
add(age);
add(input3);
add(btnSearch);
add(btnCancel);
setSize(300,200);
input1.addActionListener(this);
btnSearch.addActionListener(this);
input2.addActionListener(this);
input3.addActionListener(this);
btnCancel.addActionListener(this);
show();
}
public void actionPerformed(ActionEvent e)
{
}
}class queryFrame extends Frame implements ActionListener,ItemListener
{
TextArea input=new TextArea(10,20);
Button btnQuery,btnCancel; queryFrame()
{
super("查询所有学生信息");
btnQuery=new Button("查询");
btnCancel=new Button("取消");
add(input);
add(btnQuery);
add(btnCancel);
setSize(300,200);
input.addItemListener(this);
btnQuery.addActionListener(this);
btnCancel.addActionListener(this);
show();
}
public void actionPerformed(ActionEvent e)
{
}
public void itemStateChanged(ItemEvent e)
{
}
}

解决方案 »

  1.   

    编译时系统提示actionPerformed的public有问题,当时去掉仍然通不过
      

  2.   

    public void actionPerformed(ActionEvent e)
    是“实现接口类”的一个方法,不能将其放在该类的构造函数中,它属于该类的一个成员方法的。
      

  3.   

    才发现IDE的好,不会出现这样的问题
      

  4.   

    用jbuilder开发吧 可视化设计 代码就不会出这种问题了
      

  5.   

    upDateFrame 有个方法没有实现吧?