78 452
Assignments Done
99,6%
Successfully Done
In September 2019

Answer to Question #8929 in Java | JSP | JSF for Gavin

Question #8929
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
Expert's answer
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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions