public class Blackjack extends Applet implements ActionListener {
//Setting Up Global Variables
Button play = new Button("Play");
Button manual = new Button("User Manual");
Boolean First;
Boolean Manual;
public void init(){
//Initializing Global Variables
First=true;
Manual = false;
play.setBounds(150, 400, 50, 25);
manual.setBounds(250, 400, 110, 25);
//Initializing Window
setSize(new Dimension(500,500));
setBackground(Color.WHITE);
setLayout(null);
}
public void paint (Graphics g){
//Wipe Past Graphics
g.clearRect(0, 0, 500, 500);
//Game Start
if(First){
//Display Opening Graphics
if(!Manual){
add(play);
play.addActionListener(this);
add(manual);
manual.addActionListener(this);
setLayout(null);
g.drawImage(getImage(getDocumentBase(), "Welcome.png"), 40, 20, this);
}
//Display User Manual
else {
Button close = new Button("Close");
close.setBounds(10, 10, 40, 15);
close.addActionListener(this);
remove(play);
remove(manual);
setLayout(null);
}
}
}
@Override
public void actionPerformed(ActionEvent e) {
//Find which button was pressed.
if (e.getSource() == play) {
First=false;
repaint();
}
else if (e.getSource() == manual) {}
}
}
I know this code is really brutish, but I've spend the last 3 hours looking over Button questions here and my teacher can't help (she tried and failed to find the problem).
The issue is that when I run the code the buttons show up, but can't be clicked. It isn't that they don't respond when clicked, they just won't interact with the mouse at all (using tab/space also doesn't highlight them as one would expect it to). The strange thing is that this worked earlier today, but then stopped working after I temporarily edited out the ActionListener Override (even though Immediately put it back in. My teacher is forcing us to use Applet, so changing formats isn't an option. I'm really stuck. Thanks for any help.