0

我想问是否有人可以帮助我完成以下工作:我正在尝试用 Java 完成以下工作。我对 Java 还是很陌生,我希望能做到这一点。请注意,此 C# 代码可能不是 100% 正确,但我希望您了解我想要实现的目标。预先感谢您的协助。

//C#
//Form one
public void onFormShown(EventArgs e)
{
    if (this.User == null)
    {
        frmTwo f = new frmTwo();
        f += f_onFormClosing(EventArgs e);
        this.Hide();
    }
}

private void f_onFormClosing(EventArgs e)
{
    this.Show();
    this.User = f.User;
}

//frmTwo
private void btnClose_Click(EventArgs e)
{
    this.Close();
}

编辑:

private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
    if (loginUser.get().getUserLogin() == null) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                //Where loginUser is private AtomicReference<Singleton>
                //loginUser = new AtomicReference<Singleton>();
                //The reason for the data type here is to pass
                //the object by reference, log the user in and change
                //the value of the Main form's variable
                LoginForm login = new LoginForm(loginUser);
                login.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosing(WindowEvent we) {
                        //here I need to place the logic of
                        //setting the Main form's 'loginUser'
                        // object to the value generated in
                        //the Login form
                    }
                });
            }
        });
        this.setVisible(false);
    }
}
4

0 回答 0