A
Anabolik
For JDialog it exists the function toFront. How to implement the logic
to show the JDialog in the front of desktop every 30 seconds?
to show the JDialog in the front of desktop every 30 seconds?
Anabolik said:For JDialog it exists the function toFront. How to implement the logic
to show the JDialog in the front of desktop every 30 seconds?
Anabolik said:I found the solution.
Anabolik said:I made in Timer. Here the code:
int delay = 30000;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
myDialog.toFront();
myDialog.repaint();}
}, delay);
but my dialog did not appear on the front of all windows.
Your code is running on the wrong thread. See SwingUtilities.invokeLater.
Jim said:Your code is running on the wrong thread. See SwingUtilities.invokeLater.
Knute said:Probably not necessary. repaint() certainly not and toFront() is a
method of Window and probably doesn't need to be called on the EDT.
Lew said:Why would it not need to be called on the EDT?
There isn't anything in the Javadocs to indicate that Window is thread
safe.
Knute said:Window is an AWT component. No requirement to use the EDT on AWT
components that I know of.
Knute said:Window is an AWT component. No requirement to use the EDT on AWT
components that I know of.
For JDialog it exists the function toFront. How to implement the logic
to show the JDialog in the front of desktop every 30 seconds?
Lew said:From what I've read, all GUIs, even those not of Java, really need to
be single-threaded to work right. I've been under the impression that
this applies to AWT, too.
I need strong evidence that AWT is thread safe, not evidence that it isn't.
Knute said:Window is an AWT component. No requirement to use the EDT on AWT
components that I know of.
Knute said:You won't find a single example on Sun's web site of AWT GUI creation on
the EDT. You won't find any mention of AWT components needing to be
created on the EDT in the docs or that AWT isn't thread safe.
It is hard to prove the negative when there is no mention of the
positive, or is it the other way round?
But find me a mention in some Sun doc, tutorial or anywhere that says
that it isn't and I will quietly fade into the background .
Lew said:You're the one assuming an unprovable negative.
The literature says that all GUIs share the need to run GUI actions on
the GUI thread. You assume safety where danger might lurk without
evidence that you are correct. I assume danger with some evidence that
it might exist. Absent an authoritative assertion of safety, prudence
is the superior strategy.
The burden of proof is on the assertion of safety.
Knute Johnson said:Probably not necessary. repaint() certainly not and toFront() is a
method of Window and probably doesn't need to be called on the EDT.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.