I'm needing to make a game for my programming class but my start button wont show up
// TODO: Initialization things here.
}
/**
* This is where things will get drawn to the screen within your applet.
*/
public void paint(Graphics g)
{
// Draw our hello world
Font myFont = new Font("Ariel", Font.BOLD, 17);
g.setColor(new Color(236, 236, 236));
g.fillRect(2, 6, 640, 480);
g.setColor(Color.RED);
g.setFont(myFont);
g.drawString("In a world of good and evil, A hero must rise and save Bleedia", 25, 25);
g.drawImage(Logo, -9, 50, null);
g.drawImage(Start, -9, 50, null);
setSize(624, 500);
g.drawString("Build, Destroy, Kill, and Suicide!!!!", 200, 290);
g.drawString("E10", 590, 470);
}
}
The logo is working
I need the start button to work!
Thanks :D
1
Expert's answer
2012-11-12T05:51:50-0500
Your button is not working because there’s no definition of it at all. Examine this code, please (it shows how to create a button and set an action for it): import java.awt.event.*; import javax.swing.*; public class ButtonDemo extends JFrame implements ActionListener{ public ButtonDemo(){ setSize(400,400); JButton startButton = new JButton("Start"); add(startButton); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args){ new ButtonDemo(); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment