import java.awt.*;import java.awt.event.*; 
public class Client extends Frame implements ActionListener
{    
   Client()
   { 
     super("chat");    
     TextField text=new TextField();
     TextArea teext=new TextArea();
     this.setLocation(300, 200);
       this.setSize(244, 366);  
       this.setResizable(false);
       this.setBackground(Color.white);
       this.add(text,BorderLayout.SOUTH);
       this.add(teext,BorderLayout.NORTH);        
       addWindowListener(new WindowAdapter()
     {
     public void windowClosing(WindowEvent e)
     {
       System.exit(0);
      }
    });
    text.addActionListener(this);
   
   public void actionPerformed(ActionEvent e)
    {
     String s=text.getText().trim();
     teext.setText(s);
     text.setText("");
     }
      
    this.pack();
        this.setVisible(true);
    }
   
      
  
  
  
   
}
在编译的时候说public void actionPerformed(ActionEvent e)是个非法表达式的开始 哪个大哥帮我解决下啊

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【zhaomaoyu】截止到2008-07-18 15:49:50的历史汇总数据(不包括此帖):
    发帖的总数量:4                        发帖的总分数:40                       每贴平均分数:10                       
    回帖的总数量:3                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:4                        结贴的总分数:40                       
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    敬礼!
      

  2.   


    import java.awt.*;
    import java.awt.event.*;public class Client extends Frame implements ActionListener {

    private TextField text = new TextField();
    private TextArea teext = new TextArea(); public Client() 
    {
    super("chat"); this.setLocation(300, 200);
    this.setSize(244, 366);
    this.setResizable(false);
    this.setBackground(Color.white);
    this.add(text, BorderLayout.SOUTH);
    this.add(teext, BorderLayout.NORTH);
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e) 
    {
    System.exit(0);
    }
    });
    text.addActionListener(this);
    this.pack();
    this.setVisible(true);
    } public void actionPerformed(ActionEvent e) {
    String s = text.getText().trim();
    teext.setText(s);
    text.setText("");
    }
    }actionPerformed方法被写到构造方法里去了喵~``
      

  3.   

    1.actionPerformed(ActionEvent e)  是一个接口的方法 ,不能放在结构体里, 必须在类的结构体外部使用除非你用Actionadapterimport java.awt.*;
    import java.awt.event.*;
    public class Client extends Frame implements ActionListener
    {
       public Client()
      {
          super("chat");
          TextField text=new TextField();
          TextArea teext=new TextArea();
          this.setLocation(300, 200);
          this.setSize(244, 366); 
          this.setResizable(false);
          this.setBackground(Color.white);
          this.add(text,BorderLayout.SOUTH);
          this.add(teext,BorderLayout.NORTH);       
          addWindowListener(new WindowAdapter()
          {
              public void windowClosing(WindowEvent e)
             {
                System.exit(0);
             }
          });
          text.addActionListener(this);      this.pack();
          this.setVisible(true);
    }
        public void actionPerformed(ActionEvent e)
        {
           String s=text.getText().trim();
            teext.setText(s);
            text.setText("");
        }} 
      

  4.   

    或者import java.awt.*;
    import java.awt.event.*;
    public class Client extends Frame implements ActionListener
    {
      public Client()
      {
          super("chat");
          TextField text=new TextField();
          TextArea teext=new TextArea();
          this.setLocation(300, 200);
          this.setSize(244, 366);
          this.setResizable(false);
          this.setBackground(Color.white);
          this.add(text,BorderLayout.SOUTH);
          this.add(teext,BorderLayout.NORTH);     
          addWindowListener(new WindowAdapter()
          {
              public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
          });
          text.addActionListener(new ActionAdapter()      public void actionPerformed(ActionEvent e)
        {
          String s=text.getText().trim();
            teext.setText(s);
            text.setText("");
        });      this.pack();
          this.setVisible(true);
    }
        } 
      

  5.   

    import java.awt.*;
    import java.awt.event.*;public class Client extends Frame implements ActionListener {    private TextField text = new TextField();
        private TextArea teext = new TextArea();    public Client() {
            super("chat");        this.setLocation(300, 200);
            this.setSize(244, 366);
            this.setResizable(false);
            this.setBackground(Color.white);
            this.add(text, BorderLayout.SOUTH);
            this.add(teext, BorderLayout.NORTH);
            addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
            text.addActionListener(this);
            this.pack();
            this.setVisible(true);
        }    public void actionPerformed(ActionEvent e) {
            String s = text.getText().trim();
            teext.setText(s);
            text.setText("");
        }
        
        public static void main(String[] args) {
            new Client();
        }

      

  6.   

      private TextField text = new TextField();
        private TextArea teext = new TextArea();
    为什么这里必须声明为private
      

  7.   

    回6楼,不是必须的,其他级别同样可以,例如public我写做private只是习惯,通常不需要外部访问的属性都做此保护.
      

  8.   

    太混乱了.我建议看看 java的代码规范.
    其实整理一下程序谁都能看出问题来.....代码的规范很重要.特别是现在的软件开发都是将团队的.不规范的代码会影响开发的进度,维护,更新等问题....
    作为一个初学的人.代码的规范是起码的.不要等到以后都习惯了再来改....那样自己会很难受的