(should get username and password to procede to other frame)
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Cuizon07 {
public static void main(String[] args) {
JFrame frames = new JFrame();
frames.setVisible(true);
frames.setSize(700, 500);
frames.setResizable(false);
frames.setLocation(170, 100);
JPanel panels = new JPanel();
frames.add(panels);
panels.setBackground(new Color(56, 3, 96));
panels.setLayout(null);
JTextField tf1 = new JTextField();
panels.add(tf1);
tf1.setBounds(200, 50, 100, 25);
JLabel label1 = new JLabel("USERNAME:");
panels.add(label1);
label1.setBounds(100, 50, 150, 30);
JLabel label2 = new JLabel("PASSWORD:");
panels.add(label2);
JTextField tf2 = new JTextField();
panels.add(tf2);
tf2.setBounds(200, 100, 100, 25);
label2.setBounds(100, 100, 150, 30);
JButton button = new JButton("NEXT FRAME");
panels.add(button);
button.setBounds(500, 250, 150, 30);
String user=tf1.getText();
String pass=tf2.getText();
//getting the username and password to the user i think is correct..
if (user.equals("Dominic") && (pass.equals("1234")))
{
button.addActionListener(new copro());
JOptionPane.showMessageDialog(null, "LOGIN SUCCESSFULL");
}
else
{
tf1.setText(" ");
tf2.setText(" ");
JOptionPane.showMessageDialog(null, "INCORRECT USERNAME OR PASSWORD");
/*the else statement, joptionpane always popup after i run the program, i dont know how to correct this problem.. */
}
}
public static class copro implements ActionListener{
public void actionPerformed (ActionEvent e){
JFrame frame2 = new JFrame("NEW FRAME");
frame2.setVisible(true);
frame2.setSize(700, 500);
frame2.setLocation(170, 100);
JLabel label = new JLabel("YOU CLICKED ME");
JPanel panel2 = new JPanel();
frame2.add(panel2);
panel2.add(label);
panel2.setLayout(null);
panel2.setBackground(new Color(13, 97, 150));
label.setBounds(500, 250, 150, 30);
}
/*this is the 2nd frame after you enter the correct username and password*/
}
}