i have started to create a simple java game and at the moment i have done as much as i can possible at the moment the game builds with no errors. but it does nothing. what i want it to do is that the player enters a bid and if it is correct winner is displayed but if it is not the correct bid, higher or lower is displayed untill the correct bid is chosen. i also have a quit button that is displayed but it also does nothing i want it so that when it is clicked on the game closes. i am also in the process in addinding a reset button that will reset the game so that it can be played more than once instead of having to build and run the game every time. can anyone please help me.

the code of my game so far is displayed below it runs so if you want you can copy and past it and see what it does at the moment.
thanks nick

game code

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Frame3 extends JFrame
{


// This code sets up parts of that game that are displayed
JPanel thePanel = new JPanel();
JButton convertButton = new JButton();
JButton quitButton = new JButton();
JButton bidButton = new JButton();
JTextArea theTextArea = new JTextArea();
JTextArea enterbids = new JTextArea();
JTextArea higherlower = new JTextArea();
JLabel theLabel = new JLabel();
JTextArea errorTextArea = new JTextArea();
JTextArea resultTextArea = new JTextArea();
JTextField theTextField = new JTextField();


// once the frame is working
public Frame3()
{
}


// This method describes how to set up the frame's objects
public void initComponents() throws Exception
{
// fromthis code you can change the color of the display
Color red = new Color(255,0,0);
Color green = new Color(0,255,0);
Color black = new Color(0,0,0);
Color grey = new Color(100,100,100);
Color womble = new Color(150,200,50);


// this sets upthe size and colour of the actual applet
thePanel.setSize(new java.awt.Dimension(500,500));
thePanel.setBackground(red);


// Quit button
quitButton.setText("Quit");
quitButton.setLocation(new java.awt.Point(280, 300));
quitButton.setBackground(womble);
quitButton.setVisible(true);
quitButton.setSize(new java.awt.Dimension(100, 40));



// bidding button
bidButton.setText("Bid");
bidButton.setLocation(new java.awt.Point(100, 300));
bidButton.setBackground(womble);
bidButton.setVisible(true);
bidButton.setSize(new java.awt.Dimension(100, 40));


// Text area to display the answer
theTextArea.setText("Valued between $110,000 and $110,500");
theTextArea.setLocation(new java.awt.Point(50, 80));
bidButton.setBackground(green);
theTextArea.setEditable(false);
theTextArea.setVisible(true);
theTextArea.setSize(new java.awt.Dimension(300, 30));


// place bids here
enterbids.setText("PLLLLLACE YOUR BIDSSSS!");
enterbids.setLocation(new java.awt.Point(50, 150));
bidButton.setBackground(green);
enterbids.setEditable(true);
enterbids.setVisible(true);
enterbids.setSize(new java.awt.Dimension(300, 30));


// higher or lower
higherlower.setText("Higher or Lower!!!!!!!!!");
higherlower.setLocation(new java.awt.Point(50, 210));
bidButton.setBackground(green);
higherlower.setEditable(false);
higherlower.setVisible(true);
higherlower.setSize(new java.awt.Dimension(300, 30));


// this code enables a box to be editable so players can enter              bids
theTextField.setText("place your bids");
theTextField.setLocation(new java.awt.Point(50,  130));
theTextField.setVisible(true);
theTextField.setEditable(false);
theTextField.setSize(new java.awt.Dimension(300, 30));


setSize(500,500);
getContentPane().add(quitButton);
getContentPane().add(enterbids);
getContentPane().add(higherlower);
getContentPane().add(bidButton);
getContentPane().add(theTextArea);
getContentPane().add(theLabel);
getContentPane().add(thePanel);
getContentPane().add(errorTextArea);
getContentPane().add(resultTextArea);
getContentPane().add(theTextField);



}
}

Recommended Answers

All 2 Replies

Please indent your code next time. Sorry if it was the website that formatted it.

As for your problem, no you're not going to see anything. You have no main() method, so how can it run? So far, all you got is a couple of methods, which neither of them are getting executed.

You're only making the gui .... no calculations for the bidding. You can compare the bidding numbers ... if it is equal to the required one ... display win ... and if it is smaller or larger display likewise. All if statements in one method can do your job. Try or post again if you fail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.