开发者

why it returns null?

I have 3 classes that I have written some part of them below.when i write`this statement in AddStudent class ,it will show abcd1234 which is the password, but when I write it in the MainFrame class it will return null.why??? (I send my management object from MainFrame to the AddStudent with AddStudent's constructor) (I need the management object's information which is created in the AddStudent class in the mainframe ) what shoul开发者_如何转开发d I do?

management.getStudentsPassword();

my AddStudent class:

public class AddStudent extends javax.swing.JDialog {

private SystemManagement management;


/** Creates new form AddStudent */
public AddStudent(java.awt.Frame parent, boolean modal, SystemManagement management) {
    super(parent, modal);
    initComponents();
    this.management = management;

}

my MainFrame class:

public class MainFrame extends javax.swing.JFrame {

/** Creates new form MainFrame */
private SystemManagement management;
.
.
.}

my SystemManagement class:

private String studentsPass;
...
public void setStudentspassword(String password){
studentsPass = password;
}
public String getStudentsPassword(){
return studentsPass;
}


Reason one - password has not been set, when you call getStudentsPass() in MainFrame.

Reason two - The SystemManagement object you use in MainFrame and the one you get in AddStudent are simply not the same.

Hard to tell without more code. But I favour Reason one - check the program flow, when is the password set, when do you try to get it.


It's not clear from your question where setStudentPassword is being called from, it can't be being called if it is still leaving studentsPass null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜