mercredi 20 décembre 2017

Reflection Java Getter returning null

I have this very weird problem.

I have a UI that has a few textboxes.

Every one is linked to a documentListener that sets the value with a setter.

In the document Listener, I have used the println method to check if the data is being saved properly. It is, also, I call the getter from there, and it returns the proper value.

In another class (the UI and this class are being loaded with reflection, also, they are in the exact same location if that matters), I call the getter like this UI.getStuff(). This time, it returns null.

Here is a setter:

public static String setItem1(Object item2)
{
    JTextField a = (JTextField) item2;
    String item = a.getText();
    System.out.println(item);
    return item1 = item;
}

And here is a getter:

public static String getItem1()
{
    return item1; //Item 1 is a variable declared outside (so it's not declared inside a method)
}





Aucun commentaire:

Enregistrer un commentaire