Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java登录系统-跳过按钮_Java_Swing_Authentication_Button_Jframe - Fatal编程技术网

Java登录系统-跳过按钮

Java登录系统-跳过按钮,java,swing,authentication,button,jframe,Java,Swing,Authentication,Button,Jframe,我已经有一个功能正常的登录系统(没有数据库)。我希望发生的是,当用户单击我的登录系统上的跳过按钮时,它将直接进入我的主系统,即StudentRecords,并禁用该JFrame中的一个按钮。有可能吗? 这是我的密码: package loginSystem; import java.awt.EventQueue; public class LoginSystem { private JFrame frmLoginSystem; private JTextField txtU

我已经有一个功能正常的登录系统(没有数据库)。我希望发生的是,当用户单击我的登录系统上的跳过按钮时,它将直接进入我的主系统,即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);
    }
}


谢谢

是的,这是可能的。如何访问另一个JFrame上的按钮?“另一个JFrame”请参阅