NEed Help!!!
i am tying to make a game. here is how it should work when i press the green button , the textField in front of it should show how many times i clicked the button.
THANKS IN ADVANCE !!!!!!!!
here is the code.
FRAME:import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class HorseGameFrame extends JFrame{
private JButton Start;
private JButton Green;
private JButton Red;
private JButton Blue;
private JTextField mark1, mark2, mark3;
public HorseGameFrame(String title){
super(title);
setLayout(null);
add(theButton());
add(blueHorsebox());
add(greenHorsebox());
add(redHorsebox());
add(theTextFileds());
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(448,204);
}
public JPanel theButton() {
JPanel layoutControl = new JPanel();
layoutControl.setLayout(new GridLayout(4,1,7,5));
Start = new JButton("Start");
Start.setFont(new Font("Times", Font.BOLD, 16));
layoutControl.add(Start);
Green = new JButton("Green");
Green.setFont(new Font("Times", Font.BOLD, 16));
layoutControl.add(Green);
Red = new JButton("Red");
Red.setFont(new Font("Times", Font.BOLD, 16));
layoutControl.add(Red);
Blue = new JButton("Blue");
Blue.setFont(new Font("Times", Font.BOLD, 16));
layoutControl.add(Blue);
layoutControl.setSize(80,145);
layoutControl.setLocation(10,7);
return layoutControl;
}
public JPanel greenHorsebox(){
JPanel greenHorse = new JPanel();
greenHorse.setLayout(new GridLayout(1,10,2,2));
JLabel [] greenLabel;
greenLabel = new JLabel[10];
for(int i=0; i<greenLabel.length;++i){
JLabel aButton = new JLabel(new ImageIcon("box.gif"));
greenLabel[i] = aButton;
greenHorse.add(aButton);
aButton.setOpaque(true);
aButton.setBackground(Color.white);
aButton.setBorder(BorderFactory.createLineBorder(Color.gray));
}
greenHorse.setSize(289,32);
greenHorse.setLocation(140,44);
return greenHorse;
}
public JPanel blueHorsebox(){
JPanel blueHorse = new JPanel();
blueHorse.setLayout(new GridLayout(1,10,2,2));
JLabel [] blueLabel;
blueLabel = new JLabel[10];
for(int i=0; i<blueLabel.length;++i){
JLabel aButton = new JLabel(new ImageIcon("box.gif"));
blueLabel[i] = aButton;
blueHorse.add(aButton);
aButton.setOpaque(true);
aButton.setBackground(Color.white);
aButton.setBorder(BorderFactory.createLineBorder(Color.gray));
}
blueHorse.setSize(289,32);
blueHorse.setLocation(139,81);
return blueHorse;
}
public JPanel redHorsebox(){
JPanel redHorse = new JPanel();
redHorse.setLayout(new GridLayout(1,10,2,2));
JLabel [] redLabel;
redLabel = new JLabel[10];
for(int i=0; i<redLabel.length;++i){
JLabel aButton = new JLabel(new ImageIcon("box.gif"));
redLabel[i] = aButton;
redHorse.add(aButton);
aButton.setOpaque(true);
aButton.setBackground(Color.white);
aButton.setBorder(BorderFactory.createLineBorder(Color.gray));
}
redHorse.setSize(289,32);
redHorse.setLocation(140,119);
return redHorse;
}
public JPanel theTextFileds(){
JPanel layoutControlText = new JPanel();
layoutControlText.setLayout(new GridLayout(4,1,7,5));
JTextField mark1 = new JTextField("0");
layoutControlText.add(mark1);
JTextField mark2 = new JTextField("0");
layoutControlText.add(mark2);
JTextField mark3 = new JTextField("0");
layoutControlText.add(mark3);
layoutControlText.setSize(29,145);
layoutControlText.setLocation(100,45);
return layoutControlText;
}
/*private void updateTextField() {
mark1.setText("");
}
private void addButtonEventHandler() {
int theNumber = 0;
mark1.setText("1");
updateTextField();
}
*/
}
AND THE MAINimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class HorseGameUI extends JFrame{
public static void main(String[] args) {
// Set up the items to be put into the list
//JFrame.setDefaultLookAndFeelDecorated(true);
HorseGameFrame frame = new HorseGameFrame("GAME");
frame.setVisible(true);
}
}

