Hello! I am new to GUI Programming. We've been tasked to do a slot machine using GUI. I already made the base of the slot machine. The Problem is I cannot figure out how to input the random number generator on the two panels on the JTextField on each of them. Below is my code:
package slotMachineMain;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class slot1 {
public static void main(String[] args) {
Image icon = Toolkit.getDefaultToolkit().getImage("D:\\11.png") ;
ImageIcon image1 = new ImageIcon("D:\\12.png");
ImageIcon image2 = new ImageIcon("D:\\13.gif");
ImageIcon image3 = new ImageIcon("D:\\14.png");
JFrame frame1 = new JFrame();
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
frame1.setTitle("Take your Chance Here!");
JLabel label1 = new JLabel();
label1.setIcon(image1);
label1.setBounds(120, 10, 138, 87);
JLabel label2 = new JLabel();
label2.setIcon(image2);
label2.setBounds(0, 0, 400, 290);
JTextField text1 = new JTextField();
text1.setPreferredSize(new Dimension(80,80));
text1.setEditable(false);
JTextField text2 = new JTextField();
text2.setPreferredSize(new Dimension(80,80));
text2.setEditable(false);
JPanel panel1 = new JPanel();
panel1.setBackground(Color.white);
panel1.setBounds(83, 100, 90, 90);
panel1.add(text1);
JPanel panel2 = new JPanel();
panel2.setBackground(Color.white);
panel2.setBounds(207, 100, 90, 90);
panel2.add(text2);
JButton button1 = new JButton();
button1.setBounds(152, 200, 75, 25);
button1.setIcon(image3);
frame1.setResizable(false);
frame1.setSize(400, 290);
frame1.setLayout(null);
frame1.setIconImage(icon);
frame1.add(panel1);
frame1.add(panel2);
frame1.add(button1);
frame1.add(label1);
frame1.add(label2);
frame1.setVisible(true);
}
}