I have looked this up and cant seem to find a solution. Nothing I can find will work with my code. I really need help because i am doing this for a class project and nothing will work.
Heres what i'm trying to get it to work with.
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class enterNames extends JFrame {
public static JFrame page2 = new enterNames();
public enterNames() {
}
enterNames(String st) {
Scanner s = new Scanner(System.in);
setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Enter Names");
JLabel a1 = new JLabel("Player 1 Enter Name:");
a1.setBounds(50, 50, 400, 30);
JLabel a2 = new JLabel("Player 2 Enter Name:");
a2.setBounds(50, 150, 400, 30);
JTextField t1 = new JTextField("Enter here...");
t1.setBounds(50, 100, 400, 30);
t1.setBackground(new Color(124, 242, 0));
JTextField t2 = new JTextField("Enter here...");
t2.setBounds(50, 200, 400, 30);
t2.setBackground(new Color(124, 242, 0));
JButton b1 = new JButton("Submit");
b1.setBounds(50, 300, 400, 30);
b1.setBackground(new Color(124, 242, 0));
b1.setForeground(new Color(0, 191, 255));
add(a1);
add(a2);
add(t1);
add(t2);
add(b1);
setSize(500, 500);
SubmitListener s1 = new SubmitListener();
b1.addActionListener(s1);
}
public static void main(String[] args) {
page2.setBackground(Color.gray);
page2.setTitle("Skate Dice");
page2.setSize(500, 500);
page2.setLocationRelativeTo(null);
page2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
page2.setVisible(true);
}
class SubmitListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
openChoose();
}
}
private void openChoose() {
page2.setVisible(false);
choose page3 = new choose(null);
page3.setVisible(true);
page3.setLocationRelativeTo(null);
page3.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}