Paint(), active window, cursor
Hi,
I have the following problem:
I have a task that takes I lot of time and want a progress indicator. Fed up with trying to multithread and use progressbars (I'm on 1.5, btw), I used the Observer and Observable interfaces. Here is my monitoring class:
class monitoring implements Observer{
JFrame frame;
JTextArea text;
public monitoring(){
text = new JTextArea();
frame = new JFrame("Loading...");
frame.setContentPane(new JScrollPane(text));
frame.getContentPane().setPreferredSize(new Dimension(300, 80));
frame.pack();
frame.setVisible(false);
}
public void update(Observable sender, Object s) {
if(((String)s).compareTo("Done")==0)
frame.setVisible(false);
else{
text.setText((String)s+"\n");
frame.paint(frame.getGraphics());
frame.setVisible(true);
}
}
}
And whenever I need to refresh the message I do:
setChanged();
notifyObservers(message);
The problem is that paint causes the monitoring window to be set as the active window and grabs the cursor, not allowing me to write in other open apps while this is running. What can I do to avoid this?
Thanks in advance,
Yakov

