well, bascially i am making a little log-in system for myself.
i created a JFrame in which you create an account, when you click "ok" it pops up a window with the information you just filled in(password and username).
then if you click "OK" on that window too, i want another JFrame to pop up that actually lets you log in with the information.
how can i create 2 JFrames in a single class?
this is the code:
import javax.swing.JOptionPane; import java.awt.event.ActionListener; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import javax.swing.JLabel; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.JPasswordField; import javax.swing.JPanel; public class LogIn extends JFrame{ private JTextField txt1; private JTextField txt2; private JPasswordField ps1; private JPasswordField ps2; private JPasswordField ps3; private JLabel label1; private JLabel label2; private JLabel label3; private JLabel label4; private JLabel label5; private JButton b1; private JButton b2; public LogIn(){ super("Account"); setLayout (new FlowLayout()); label1 = new JLabel("Enter your username: "); txt1 = new JTextField(10); label2 = new JLabel("Enter your password: "); ps1 = new JPasswordField(10); label3 = new JLabel("Confirm your password: "); ps2 = new JPasswordField(10); b1 = new JButton("OK"); add(label1); add(txt1); add(label2); add(ps1); add(label3); add(ps2); add(b1); thehandler handler = new thehandler(); b1.addActionListener(handler); } public class thehandler implements ActionListener{ public void actionPerformed(ActionEvent event){ if(txt1.getText().equals(ps1.getText())){ JOptionPane.showMessageDialog(null, "Password error, your username can't be the same as your password","Password Error!",JOptionPane.ERROR_MESSAGE);} else if(ps1.getText().equals(ps2.getText())){ JOptionPane.showMessageDialog(null, "Account information: "+"\n"+"User: "+txt1.getText()+"\n"+"Password: "+ps1.getText(), "Account Information", JOptionPane.INFORMATION_MESSAGE);} else{ JOptionPane.showMessageDialog(null, "Passwords did not match! Try again please!", "Password error!", JOptionPane.ERROR_MESSAGE);} } } }