I am a relative newbie to Java, and have a program that runs in a dos window that reads data. It creates a graphic window that displays the data. This all works fine except that I need to use a readLine () method in my dos window and when the graphic window is created it has the focus.
I want to make the dos window the active window, but have not found the right combination, other than a mouse click to get back to the dos window.
I also tried creating the graphic display in a thread implementing Runnable and sending the data to the thread, which also worked, but had the same problem with focus. I tried sleep() and wait() methods in the thread, but that didn't work either. I think the answer is using focus, but was confused by just how to implement this. Please be specific in your answer if possible.
class Test implements WindowListener, ActionListener {
...define static variables...
static JFrame jf=new JFrame ();
static JPanel jp=new JPanel ();
...create some labels and add to jp...
...add window events to jf...
jf.setVisible (true);
while (true) {
getData ();
updateDisplay ();
}
static void getData () {
...create BufferedReader br...
data=br.readLine ();
return data;
}
updateDisplay () {
label1.setText (data);
...send additional data to other labels in jp...
}
...window event methods, etc...
}
I want to make the dos window the active window, but have not found the right combination, other than a mouse click to get back to the dos window.
I also tried creating the graphic display in a thread implementing Runnable and sending the data to the thread, which also worked, but had the same problem with focus. I tried sleep() and wait() methods in the thread, but that didn't work either. I think the answer is using focus, but was confused by just how to implement this. Please be specific in your answer if possible.
class Test implements WindowListener, ActionListener {
...define static variables...
static JFrame jf=new JFrame ();
static JPanel jp=new JPanel ();
...create some labels and add to jp...
...add window events to jf...
jf.setVisible (true);
while (true) {
getData ();
updateDisplay ();
}
static void getData () {
...create BufferedReader br...
data=br.readLine ();
return data;
}
updateDisplay () {
label1.setText (data);
...send additional data to other labels in jp...
}
...window event methods, etc...
}