У меня уже есть действующая система входа в систему (без базы данных). Я хочу, чтобы, когда пользователь нажимал кнопку «Пропустить» в моей системе входа в систему, он напрямую go переходил в мою основную систему, которая представляет собой StudentRecords, и отключал кнопку в этом JFrame. Возможно ли это случиться? Вот мой код:
package loginSystem;
import java.awt.EventQueue;
public class LoginSystem {
private JFrame frmLoginSystem;
private JTextField txtUsername;
private JPasswordField txtPassword;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LoginSystem window = new LoginSystem();
window.frmLoginSystem.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public LoginSystem() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmLoginSystem = new JFrame();
frmLoginSystem.setBounds(100, 100, 450, 300);
frmLoginSystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmLoginSystem.getContentPane().setLayout(null);
JLabel label = new JLabel("Admin ID:");
label.setFont(new Font("Tahoma", Font.BOLD, 17));
label.setBounds(34, 81, 122, 42);
frmLoginSystem.getContentPane().add(label);
txtUsername = new JTextField();
txtUsername.setColumns(10);
txtUsername.setBounds(168, 93, 214, 22);
frmLoginSystem.getContentPane().add(txtUsername);
JLabel label_1 = new JLabel("Password:");
label_1.setFont(new Font("Tahoma", Font.BOLD, 17));
label_1.setBounds(35, 118, 122, 42);
frmLoginSystem.getContentPane().add(label_1);
JLabel label_2 = new JLabel("Security Check");
label_2.setFont(new Font("Tahoma", Font.BOLD, 20));
label_2.setBounds(135, 35, 151, 22);
frmLoginSystem.getContentPane().add(label_2);
JButton button = new JButton("Login");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String password = txtPassword.getText();
String username = txtUsername.getText();
// txtPassword.setEchoChar('0');
if (password.contains("admin") && username.contains("admin")) {
txtPassword.setText(null);
txtUsername.setText(null);
//StudentRecords info = new StudentRecords();
StudentRecords.main(null);
frmLoginSystem.setVisible(false);
// info.main(null);
}
else
{
JOptionPane.showMessageDialog(null, "Invalid Login Details","Login Error",JOptionPane.ERROR_MESSAGE);
txtPassword.setText(null);
txtUsername.setText(null);
}
}
});
button.setFont(new Font("Tahoma", Font.BOLD, 20));
button.setBounds(296, 165, 97, 33);
frmLoginSystem.getContentPane().add(button);
JButton btnReset = new JButton("Exit");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frmLoginSystem = new JFrame("Exit");
if (JOptionPane.showConfirmDialog(frmLoginSystem, "Confirm if you want to exit", "Login System",
JOptionPane.YES_NO_OPTION)== JOptionPane.YES_NO_OPTION) {
System.exit(0);
}
}
});
btnReset.setFont(new Font("Tahoma", Font.BOLD, 20));
btnReset.setBounds(165, 183, 97, 33);
frmLoginSystem.getContentPane().add(btnReset);
JButton button_1 = new JButton("Clear");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtUsername.setText(null);
txtPassword.setText(null);
}
});
button_1.setFont(new Font("Tahoma", Font.BOLD, 20));
button_1.setBounds(34, 183, 97, 33);
frmLoginSystem.getContentPane().add(button_1);
txtPassword = new JPasswordField();
txtPassword.setBounds(168, 130, 214, 22);
frmLoginSystem.getContentPane().add(txtPassword);
JButton btnSkip = new JButton("Skip");
btnSkip.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
StudentRecords.main(null);
}
});
btnSkip.setFont(new Font("Tahoma", Font.BOLD, 20));
btnSkip.setBounds(296, 207, 97, 33);
frmLoginSystem.getContentPane().add(btnSkip);
}
}
Спасибо!