I'm getting this error when trying to compile: File: C:\Users\Jake\Java\defaultFrameSubClass.… [line: 46]
Error: cannot find symbol
symbol : variable clickedButton
location: class defaultFrameSubClass
I am completely new to java, am taking a class on it and I can't figure out what the problem is.
Here is the code: import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class defaultFrameSubClass extends JFrame implements ActionListener {
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT = 200;
private static final int FRAME_X_ORIGIN = 150;
private static final int FRAME_Y_ORIGIN = 250;
private static final int BUTTON_WIDTH = 80;
private static final int BUTTON_HEIGHT = 30;
private JButton cancelButton;
private JButton okButton;
public defaultFrameSubClass() {
Container contentPane = getContentPane();
setTitle ("My First Subclass");
setSize (FRAME_WIDTH,FRAME_HEIGHT);
setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
//set the layout manager
contentPane.setLayout(new FlowLayout());
//create and place two new buttons on the frame's content pane
okButton = new JButton("OK");
okButton.setSize(BUTTON_WIDTH,BUTTON_HEI…
contentPane.add(okButton);
cancelButton = new JButton ("CANCEL");
cancelButton.setSize(BUTTON_WIDTH,BUTTON…
contentPane.add(cancelButton);
//register this frame as an action listener of the two buttons
cancelButton.addActionListener(this);
okButton.addActionListener(this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}//end constructor
public void actionPerformed(ActionEvent event){
JButton clickedButon = (JButton) event.getSource();
String buttonText = clickedButton.getText();
setTitle("You clicked " + buttonText);
}//end method actionPerformed
}//end class
This "assignment" I am just copying stuff out of the book, but I am not getting the same results! There is this error that I'm getting now, and I've also gotten an error about this line as well :
class defaultFrameSubClass extends JFrame implements ActionListener {
/ In that error it said something about not being able to override something :O. Guess I should have saved the error.

