views:

53

answers:

3

I would like to create a series of new windows when I click labels containing information. I want these windows to be orphaned. Is there a way to pass a static variable to a class and tell it to keep monitoring the status of that variable?

Basically I want to say

    NewOrphanedWindow.main(StaticClass.ValueToMonitorFromNowOn);

Is there a way to do this, or does it have to be programmed on the other side?

I basically want a window that will receive a variable String name and then use that variable String to reference the actual static variable.

A: 

You could run a thread in your window class which checks the value of the variable every X seconds and responds accordingly:

Thread monitor = new Thread(){
  public void run(){
    while(true){
      //check the value of StaticClass.ValueToMonitorFromNowOn
      try{
        Thread.sleep(1000); //sleep 1 sec
      } catch (InterruptedException e){
        break;
      }
    }
  }
}
monitor.start();
Michael Angstadt
A: 

Not sure what exactly you are trying to do, but you can achieve it by setting a static variable before calling main:

NewOrphanedWindow.monitor = StaticClass.ValueToMonitorFromNowOn;
Omry
I have a list of variables in a table. The user wants to see that section of the table in a new window where they can resize it so that it is fullscreen. So on-click open a new window with just that information and orphan it so that it just monitors what it needs to monitor regardless of the rest of the program.
Adam Outler
You problem description is too vague for me.
Omry
I'm writing an OBD II interpereter program. I am creating a table of available values. When the option is clicked, a new window should pop up containing a gauge and a value.
Adam Outler
okay, so why not initialize a new window when an option is clicked and pass relevant parameters into it?
Omry
A: 

Lookup table is the way to go

Adam Outler