构造函数写错了,应该是FrameInOut2,不是FrameInOut

解决方案 »

  1.   

    你昨天的帖子,为什么重复发呢??
    http://expert.csdn.net/Expert/topic/1352/1352101.xml?temp=.9081842
    大概又是类名不注意的问题
      

  2.   

    FrameInout2 这个类的声明也要注意大小写
      

  3.   

    回复人: beyond_xiruo(希偌) :
          老兄,这一个是不一样的,它又多加了一个开关,我照你的方法编了 还是不行,帮帮忙吧!!!!!!!!!
      

  4.   

    这个是修改之后的程序:
    import java.awt.*;
    import java.awt.event.*;
    public class csdn12
    {
    public static void main(String args[])
    {
    new FrameInOut2();
    }
    }
    class FrameInOut2 extends Frame implements ActionListener
    {
    Label prompt ;
    TextField input,output;
    Button btn;
    FrameInOut2()
    {
    super("图形界面的Java Application程序");
    prompt=new Label("please enter your name:");
    input=new TextField(6);
    output=new TextField(20);
    btn=new Button("close");
    setLayout(new FlowLayout());
    add(prompt);
    add(input);
    add(output);
    add(btn);
    input.addActionListener(this);
    btn.addActionListener(this);
    setSize(300,200);
    show();
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==input)
    output.setText(input.getText()+",欢迎您!");
    else
    {
    dispose();
    System.exit(0);
    }
    }
    }
    你错误的地方在于:
    1、FrameInOut应该是FrameInOut2(注意大小写!!!);
    2、prompt=new Label("please enter your name:");的分号应该在把输入法去掉的情况下输入;
    3、btn=new Button("close");的分号应该在把输入法去掉的情况下输入;