I can not get this Rock, Paper, Scissor game into a GUI interface. The interface itself does not display the given buttons unless you resize the screen. And it will show the computer's choice in the Build output but I don't know how to transfer that to the GUI.. If anyone can help me complete this I will wire some cash, send a check/money order anything. I really need this done by tomorrow and am giving in to help at whatever cost it may be. Here is the code thus far...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class kthLab4 extends JFrame
{
private JButton one, two, three;
private JTextArea results;
int userChoice;
int compChoice;
public kthLab4()
{
super("GAME");
setSize(350,550);
setVisible(true);
Random generator = new Random();
one = new JButton("Rock");
two = new JButton("Paper");
three = new JButton("Scissors");
results = new JTextArea(6,20);
Container content = getContentPane();
content.setLayout (new BorderLayout());
JPanel panel = new JPanel(new FlowLayout());
panel.add(one);
panel.add(two);
panel.add(three);
content.add(panel, BorderLayout.NORTH);
content.add(results, BorderLayout.CENTER);
one.setActionCommand("rock");
two.setActionCommand("paper");
three.setActionCommand("scissors");
one.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
userChoice = 1;
System.out.println("Rock");
compChoice = pickNum();
System.out.println(compChoice);
}
}
);
two.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
userChoice = 2;
System.out.println("Paper");
compChoice = pickNum();
System.out.println(compChoice);
}
}
);
three.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
userChoice = 3;
System.out.println("Scissors");
compChoice = pickNum();
System.out.println(compChoice);
}
}
);
}
public int pickNum()
{
int value=(int)(Math.random() * 3)+1;
return value;
}
public static void main(String args[])
{
kthLab4 application = new kthLab4();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void getResults(int uc, int cc, String m)
{
if(uc == cc)
{
m = "tie";
}
}
}