11
Java / Re: java applet problems
« on: April 24, 2006, 09:23 AM »
I know but I earlier on in the applet I have set the Desert class as a super class
and in this class doesn't everytime I have main mean that I'm telling the code to look in the Desert class for the method?
//sets the Desert class as the super class
public Desert() {
super();
}
public Desert() {
super();
}
and in this class doesn't everytime I have main mean that I'm telling the code to look in the Desert class for the method?
final class ControlsPanel extends JPanel implements ActionListener {so using the same thinking thats what I tried to do with the Jeep class, but for some reason it doesn't seem to work in this class.
private JButton bReset, bRules, bSolution;
private JPanel buttonsPanel;
private Desert main;
// constructor
ControlsPanel(Desert main) {
this.main = main;
panel code goes here
}
public void actionPerformed (ActionEvent e) {
if (e.getSource() == bRules) {
JOptionPane.showMessageDialog(null, main.rules(), "Rules", JOptionPane.INFORMATION_MESSAGE);
}
if (e.getSource() == bReset) {
int userResponse = JOptionPane.showConfirmDialog(null, "Are you sure you want to reset?", null, JOptionPane.YES_NO_OPTION);
if (userResponse == JOptionPane.YES_OPTION) {main.newGame();}
if (userResponse == JOptionPane.NO_OPTION) {};
}
if (e.getSource() == bSolution) {
int userResponse = JOptionPane.showConfirmDialog(null, "Are you sure you want to see the solution?", null, JOptionPane.YES_NO_OPTION);
if (userResponse == JOptionPane.YES_OPTION) {main.solution();}
if (userResponse == JOptionPane.NO_OPTION) {};
}
}
}