其他的也没几行,主要的代码就是这些了!
是不是我必须要把label声明为final啊?

解决方案 »

  1.   

    label.setBounds (shell.getClientArea ());
      

  2.   

    你的这些代码是不是写在STATIC方法内的?如果是你的LABALE要定义成FINAL
      

  3.   

    我给你个简单的代码:
    这是第一种方法:public class myframe extends Frame
    {
      ……
      TextFiled txt;
      Button bon;
      …… 
      myframe()
      {
       ……
       txt = new TextFiled(10);
       bon = new Button("OK");
       bon.addActionListener(action);
      };
      ……
    }
    class action implements ActionListener 
    {
      TextFiled text;
      action(TextFiled t)
      {
         text = t;
      }
      public void AcitonPerformed(ActionEvent e)
      {
         text.setText("Ok!");
      }
    }这是第二种方法:
    public class myframe extends Frame
    {
      ……
      TextFiled txt;
      Button bon;
      …… 
      myframe()
      {
       ……
       txt = new TextFiled(10);
       bon = new Button("OK");
       bon.addActionListener(action);
      };
      ……
      class action implements ActionListener   //这个就称为内部类!
      {
        public void AcitonPerformed(ActionEvent e)
        {
           txt.setText("Ok!");
        }
      }
    }