From: Knute Johnson on
Knute Johnson wrote:
> Lew wrote:
>> Knute Johnson wrote:
>>> Jim Janney wrote:
>>>> Anabolik <bumsys(a)gmail.com> writes:
>>>>
>>>>> 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.
>>>>
>>>
>>> Probably not necessary. repaint() certainly not and toFront() is a
>>> method of Window and probably doesn't need to be called on the EDT.
>>
>> 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.
>>
>
> Window is an AWT component. No requirement to use the EDT on AWT
> components that I know of.
>

I'm not really sure the toFront() and toBack() is the way to get this to
work. toFront() only puts the window in front of other windows in the
same VM. The setAlwaysOnTop() works fine on my XP box though.

--

Knute Johnson
email s/nospam/knute2009/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
From: Lew on
Knute Johnson wrote:
> Window is an AWT component. No requirement to use the EDT on AWT
> components that I know of.

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.

--
Lew
From: Roedy Green on
On Wed, 4 Nov 2009 01:19:41 -0800 (PST), Anabolik <bumsys(a)gmail.com>
wrote, quoted or indirectly quoted someone who 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?

see http://mindprod.com/jgloss/timer.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

An example (complete and annotated) is worth 1000 lines of BNF.
From: Knute Johnson on
Lew wrote:
> Knute Johnson wrote:
>> Window is an AWT component. No requirement to use the EDT on AWT
>> components that I know of.
>
> 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.
>

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 :-).

--

Knute Johnson
email s/nospam/knute2009/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
From: markspace on
Knute Johnson wrote:

> Window is an AWT component. No requirement to use the EDT on AWT
> components that I know of.
>


Window is an AWT component, but JDialog is a Swing component. And it's
objects which need to be synchronized, not method calls. If AWT doesn't
deal with Swings synchronization properly (and I don't see how it could)
there's still a need for thread safety on the caller's part.

I don't seen any methods at all marked as thread safe in JDialog's docs.
I think all of it's methods, including inherited ones, should be
called only on the EDT.