Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in "Headfirst Java"

 
George Sarbu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello! When I try to compile a code from the great book "Head First Java",chapter 12(about GUI), i got an error.
The code is:

import javax.swing.*;
import java.awt.event.*;

public class SimpleGui1B implements ActionListener {


public static void main(String[] args) {

SimpleGui1B gui=new SimpleGui1B();
gui.go();
}

public void go() {

JFrame frame=new JFrame();

JButton buton=new JButton("click");

buton.addActionListener(this);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(buton);



frame.setSize(400, 300);

frame.setVisible(true);
}

public void actionPerformed(ActionEvent event) {
buton.setText("I've been clicked");
}


}

Error:
cannot find symbol
symbol:variable buton
location: class SimpleGui1B
buton,setText("I've been clicked")
^
1 error


Please help me !!!
 
xiss burg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic