public static void main(String args[])
是 static 的,所以只能调用 static 的函数;
而 setBounds 的定义是:
public void setBounds(int x,
                      int y,
                      int width,
                      int height)
懂了吗其实 这些画界面的东东最好都放在构造函数里

解决方案 »

  1.   

    这样就不会出错了:
    import java.awt.*;
    import java.awt.event.*;public class Ch7_1 extends Frame{  Label lbl1 = new Label("count the click ");
      Button button1 = new Button("count");
      int count=0;
      public static void main(String args[]) {
        Ch7_1 frame1 = new Ch7_1();
        frame1.setTitle("") ;
        frame1.setBackground(Color.pink) ;
        frame1.setLayout(null);
        frame1.setSize(200,200) ;
        frame1.lbl1.setBounds(5,20,150,25) ;
        frame1.button1.setBounds(5,50,75,25) ;
        frame1.setVisible(true) ;
      }
      
      public Ch7_1() {
        
        add(lbl1);
        add(button1);
        button1.addActionListener(new ActionLis()) ;
      }
      
      class ActionLis implements ActionListener {
        public void actionPerformed(ActionEvent e) {
          count++;
          lbl1.setText("click's count is :" + count) ;
        }
      }
    }
      

  2.   

    类型为 static 的函数不能访问类的 instance member, 因为有可能类并没有被实例化。