Results 1 to 5 of 5
Thread: Need help in Guessing Game
- 10-27-2010, 01:23 PM #1
Member
- Join Date
- May 2008
- Posts
- 6
- Rep Power
- 0
Need help in Guessing Game
Create a Java JFrame Guessing Game GUI. The GUI should supply a number of button (minimum twelve) with images attached to each button. When the GUI starts the buttons will display a question mark character (“?”; in a nice big format), when the user clicks on one of the buttons an image will be revealed to the user, e.g. it could be an image of an animal. There must be two of each image hidden behind the buttons on the screen, i.e., there are matching pairs to reveal. The user will continue to reveal each of the buttons’ contents until all matching images have been revealed. The score (number of matches) must be displayed on the GUI somewhere, and the user must be informed that they have won the game. A button should also be supplied to reset the game
Here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Guessing extends JFrame implements ActionListener{
public Guessing() {
super("Guessing Game");
Container contentPane = getContentPane();
JPanel panel = new JPanel();
JButton myButton1 = new JButton("?");
myButton1.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton2 = new JButton("?");
myButton2.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton3 = new JButton("?");
myButton3.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton4 = new JButton("?");
myButton4.setFont(new Font("Serif", Font.BOLD,20))
JButton myButton5 = new JButton("?");
myButton5.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton6 = new JButton("?");
myButton6.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton7 = new JButton("?");
myButton7.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton8 = new JButton("?");
myButton8.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton9 = new JButton("?");
myButton9.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton10 = new JButton("?");
myButton10.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton11 = new JButton("?");
myButton11.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton12 = new JButton("?");
myButton12.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton13 = new JButton("?");
myButton13.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton14= new JButton("? ");
myButton14.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton15 = new JButton("?");
myButton15.setFont(new Font("Serif", Font.BOLD,20));
JButton myButton16 = new JButton("?");
myButton16.setFont(new Font("Serif", Font.BOLD,20));
// ADD THE ACTIONLISTENER
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
button6.addActionListener(this);
button7.addActionListener(this);
button8.addActionListener(this);
button9.addActionListener(this);
button10.addActionListener(this);
button11.addActionListener(this);
button12.addActionListener(this);
button13.addActionListener(this);
button14.addActionListener(this);
button15.addActionListener(this);
button16.addActionListener(this);
//ADD THE BUTTONS TO THE TABLE
panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(button5);
panel.add(button6);
panel.add(button7);
panel.add(button8);
panel.add(button9);
panel.add(button10);
panel.add(button11);
panel.add(button12);
panel.add(button13);
panel.add(button14);
panel.add(button15);
panel.add(button26);
//ADD THE PANEL TO THE FRAME ANDDISPLA
c.add(panel);
setSize(400,300);
show();
}// END CONSTRUCTOR
public static void main(String args [])
{
Guessing myFrame = new Guessing();
myFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}//end of class
- 10-27-2010, 01:32 PM #2
Okay, and what's your question? Make sure you use the code tags when posting code.
Read this: How To Ask Questions The Smart Way
-
This is a code dump type question where you have posted the assignment, then the code without asking any questions other than the implied question, "here's my code, fix it for me". You may want to fix this post, since these type of questions generally don't get answered. I suggest you start by asking as specific a question as possible.
- 10-27-2010, 07:58 PM #4
Double posted 13 minutes after Fubarable's response here.
Guessing Game
db
-
Last edited by Fubarable; 10-27-2010 at 10:57 PM.
Similar Threads
-
Java - number guessing game
By kev670 in forum Java AppletsReplies: 3Last Post: 10-22-2010, 12:55 AM -
Help with a word guessing game.
By The_Round_One in forum New To JavaReplies: 6Last Post: 05-19-2010, 04:22 AM -
guessing game help
By yasmin k in forum AWT / SwingReplies: 4Last Post: 10-31-2009, 05:37 PM -
guessing game using GUI
By yasmin k in forum New To JavaReplies: 1Last Post: 10-26-2009, 12:13 PM


LinkBack URL
About LinkBacks


Bookmarks