First off, I am pretty new to java and I am just staring to get the hang of how static classes can interface with non-static classes and how to get a static class to update a textbox.
I keep searching for information, but I cannot find anything. I need a variable listener. here is something like what I am trying to do:
public class Class1{
public static int X;
public static void Process(){
for (true){
X = X + 1;
}
}
Then I have another class where I want to bind a variable to a textbox
Public class Class2{
****** On Class1.X.changeValue { Form.jLabel1.setText(Class1.X) }
}
I hope I was clear on what I am trying to do. I am trying to bind a label to a variable.
In Java there is no language specific way to have listeners on variables. What you will need to do is when your code changes the variable then have it also update the JLabel.
You can have listeners on buttons and other UI widgets and they might update the JLabel.
One way you might implement this is as follows. Do you know about getters and setters ? They are methods that do the getting and setting of instance variables.
You should really try to minimize the use of statics as much as possible, They tend to encourage “Global Variables”