JButton jButton = new JButton("停止");
jButton .addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        if(e.getActionCommand().equals("停止")){
            jButton .setText("开始");
        }
    }
});

解决方案 »

  1.   

    final JButton jButton = new JButton("停止");
            jButton .addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if(e.getActionCommand().equals("停止")){
                        jButton .setText("开始");
                    }
                }
            });
    inner class 只能访问final的局部变量
      

  2.   

    楼上讲得有道理,还可以把JButton jButton = new JButton("停止");写到全局位置也是可以的!