Prev: Redirecting System.out and exotic characters
Next: How would I rewrite this to satisfy the code checker?
From: Jim Janney on 4 Nov 2009 14:15 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 4 Nov 2009 14:46 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 4 Nov 2009 20:31 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 4 Nov 2009 23:32 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 4 Nov 2009 23:47 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
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Redirecting System.out and exotic characters Next: How would I rewrite this to satisfy the code checker? |