From: Jim Janney on
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.

--
Jim Janney
From: Bent C Dalager on
On 2009-11-04, Jim Janney <jjanney(a)shell.xmission.com> 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.

Or use javax.swing.Timer instead of java.util.Timer.

Cheers,
Bent D
--
Bent Dalager - bcd(a)pvv.org - http://www.pvv.org/~bcd
powered by emacs
From: Knute Johnson on
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.

--

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

--
Lew
From: Knute Johnson on
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.

--

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