[sorry for the crosspost: I just posted in java.programmer,
but I think that this is the right group for this question]
hi all,
I have a button which opens a window with some drawing.
I havea slow initialization phase, so I'd like to show a
dialog window with the message "initializing..."
My coinvoking code is something like:
private void doMap(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.out.println("Launching Configure Maps");
// INVOCATION 1
WaitingWindowUI ww = new WaitingWindowUI("xxxxx");
// INVOCATION 2
Configuremapandsensors conf = new Configuremapandsensors();
conf.setVisible(true);
}
the proble is that if I call INVOCATION 1 (and comment out INVOCATION2)
I see my pop up window with the message, if I comment out INVOCATION1
and call just INVOCATION 2 I got my window after some seconds,
but if I call INVOCATION 1 and INVOCATION 2 I see a rectangle where
there should be my waiting message, and after some second I see
my window and the waiting message.
It seems that when I call
WaitingWindowUI ww = new WaitingWindowUI("xxxxx");
it is not shown until the window of INVOCATION 2 is complete.
What am I missing?
How can I force to show the waiting message?
Any examples of this kind?
(by the way, I tried ww.setVisible(true) or ww.show(0, with no results)
thanks
giammy
Andrew Thompson - 27 Jul 2006 15:50 GMT
> [sorry for the crosspost: I just posted in java.programmer,
> but I think that this is the right group for this question]
Multi-post actually, but providing an (entirely reasonable)
explanation is good.
(And yes, this is a better group for GUI matters)
> I have a button which opens a window with some drawing.
> I havea slow initialization phase, so I'd like to show a
> dialog window with the message "initializing..."
..
> it is not shown until the window of INVOCATION 2 is complete.
Your sensible use of Usenet suggests you might be
proficient at searching as well, so I'll give you a search tip..
block+"event+dispatch+thread"+java
..leads to loads of good hits on the fundamental problem
that affects this GUI.
And as an aside, this group has an FAQ posted regularly that
has more detailed information on blocking the EDT, as well
as lots of other invaluable information for Java GUI developers.
Now.. did you remember to report the end of the
thread on c.l.j.p.?
Andrew T.
Brandon McCombs - 28 Jul 2006 02:16 GMT
> [sorry for the crosspost: I just posted in java.programmer,
> but I think that this is the right group for this question]
[quoted text clipped - 38 lines]
> thanks
> giammy
Basically you need to have a separate thread running that draws your
waiting message because what you are seeing is both your window and your
message vying for the CPU and one is going to make it there first (to
the CPU) and stay there until it is done and then the other action will
get its turn. To have both of them have a fair shot at the CPU you need
to put them into threads.
Nicky - 29 Jul 2006 09:34 GMT
Hi,
I think u should put INVOCATION1 in a seperated thread, and set it's
priority maximum, so it can be displayed fast. U can edit ur code like
this.
private void doMap(java.awt.event.ActionEvent evt) {
System.out.println("Launching Configure Maps");
// INVOCATION 1
Thread t = new Thread( new Runnable(){
public void run(){
WaitingWindowUI ww = new WaitingWindowUI("xxxxx");
}
});
t.setPriority(Thread.MAX_PRIORITY);
t.start();
// INVOCATION 2
Configuremapandsensors conf = new Configuremapandsensors();
conf.setVisible(true);
}
Hope it works !