I am making a game, but my buttons don't seem to be working. When I click in a certain area (where the button is) a screen should pop up. It doesn't. Please help.
// The "VirusMania" class.
import java.applet.*;
import java.awt.*;
import javax.swing.Timer;
import java.awt.event.*;
public class VirusMania extends Applet implements MouseListener, ActionListener
{
// Place instance variables here
Image bg, upgradebg, worldbg, upgradeb, worldb, xb, encb, trojanb, wormb, hackPWb, rootb, hyperb, popb, passProtectb, ovwb, delb, runVirb, infFilesb, lBombb;
int cash = 500, time = 0;
Font money = new Font ("Arial", 10, 25);
Timer infect;
int infected;
int launch = 0;
int na = 1, sa = 0, euro = 0, asia = 0, aust = 0;
int enc, trojan, worm, hackPW, root, hyper, pop, passProtect, ovw, del, runVir, infFiles, lBomb;
int email, software;
int menu = 0, upgrade = 0;
int mx, my;
public void init ()
{
infect = new Timer (5000, this);
infect.setInitialDelay (10000);
bg = getImage (getDocumentBase (), "Map2.jpg");
upgradebg = getImage (getDocumentBase (), "upgradebg.gif");
worldbg = getImage (getDocumentBase (), "worldbg.gif");
upgradeb = getImage (getDocumentBase (), "upgradeb.jpg");
worldb = getImage (getDocumentBase (), "worldb.jpg");
xb = getImage (getDocumentBase (), "xb.jpg");
encb = getImage (getDocumentBase (), "encryptb1.jpg");
trojanb = getImage (getDocumentBase (), "trojanb1.jpg");
wormb = getImage (getDocumentBase (), "wormb1.gif");
hackPWb = getImage (getDocumentBase (), "hackpwb1.jpg");
rootb = getImage (getDocumentBase (), "rootb1.gif");
hyperb = getImage (getDocumentBase (), "hyperb1.jpg");
popb = getImage (getDocumentBase (), "popb1.jpg");
passProtectb = getImage (getDocumentBase (), "passprotectb1.jpg");
ovwb = getImage (getDocumentBase (), "ovwb1.jpg");
delb = getImage (getDocumentBase (), "delb1.jpg");
runVirb = getImage (getDocumentBase (), "runb1.jpg");
infFilesb = getImage (getDocumentBase (), "infb1.jpg");
lBombb = getImage (getDocumentBase (), "bombb1.jpg");
// Place the body of the initialization method here
} // init method
public void start ()
{
// Start the timer
infect.start ();
}
public void paint (Graphics g)
{
g.drawImage (bg, 0, 0, 800, 600, this);
g.setFont (money);
g.setColor (Color.green);
g.drawString ("Money: " + cash, 20, 20);
g.drawString ("Time: " + time, 100, 70);
g.drawImage (upgradeb, 275, 525, 100, 50, this);
g.drawImage (worldb, 400, 525, 100, 50, this);
if (launch == 1)
{
g.drawString ("The Virus Has Lauched", 275, 20);
if (infected == 1)
{
g.drawString ("Infected", 100, 100);
}
}
if (upgrade == 1)
{
g.drawImage (upgradebg, 100, 100, this);
}
else if (menu == 1)
{
g.drawImage (worldbg, 100, 100, this);
}
// Place the body of the drawing method here
} // paint method
public void mousePressed (MouseEvent e)
{
if (menu == 0 && upgrade == 0)
{
if (mx > 275 && mx < 375 && my > 525 && my < 575)
{
upgrade = 1;
repaint();
}
else if (mx > 400 && mx < 500 && my > 525 && my < 575)
{
menu = 1;
repaint();
}
}
}
public void mouseReleased (MouseEvent e)
{
}
public void mouseClicked (MouseEvent e)
{
}
public void mouseEntered (MouseEvent e)
{
}
public void mouseExited (MouseEvent e)
{
}
public void mouseMoved (MouseEvent e)
{
mx = e.getX ();
my = e.getY ();
}
public void mouseDragged (MouseEvent e)
{
}
public void actionPerformed (ActionEvent e)
{
double infecting = Math.random ();
time += 1;
launch = 1;
if (infecting > .9)
{
infected = 1;
}
repaint ();
}
} // VirusMania class
thanks for any help.