Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1782

Re: Can a jPanel's backgr

From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: Can a jPanel's backgr
Message-ID <737c4e55bac1d@uwe> (permalink)
Newsgroups comp.lang.java.gui
References <1181468093_2183@sicinfo3.epfl.ch>
Date 2011-04-27 15:35 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Philipp wrote:
>Andrew Thompson a |-crit :
>>>> In any case, it is possible to *extend* JPanel (or jPanel, 
>>>> I am guessing) to provide a method that will do that.
..

Please refrain from 'full-quoting'.  Selective trimming 
of earlier posts does wonders.  Note that my current
web interface to usenet automatically trims most text
before I get to reply.

>Shouldn't the GUI be updated from the EDT thread? How would this be done?

Yes and no.

The 'rule' is that UI updates outside the EDT should
be updated using invokeLater, something like..

<snippet>
  public void run() {
    while (true) {
      if ( flashing ) {
        active = !active;
        Runnable r = new Runnable(){
          public void run(){
            repaint();
          }
        };
        EventQueue.invokeLater(r);

        if ( System.currentTimeMillis()-startFlash>lengthFlash ) {
          flashing = false;
        }
      }
      try {
        Thread.sleep(400);
      } catch (InterruptedException ie) {
        // wake and continue
      }
    }
  }
</snippet>

I say 'rule' because I have never observed any GUI
problems to be caused by ignoring it.

(shrugs) YMMV.

[ Waits for the invokeLater devotees to jump in with
lots of long words and remonstrations - with no code 
that can back up the claims. ]

-- 
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200706/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can a jPanel's background "JT" <jt@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: Can a jPanel's backgr "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: Can a jPanel's backgr "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
    Re: Can a jPanel's backgr "JT" <jt@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
      Re: Can a jPanel's backgr "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
        Re: Can a jPanel's backgr "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
          Re: Can a jPanel's backgr "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
            Re: Can a jPanel's backgr "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
            Re: Can a jPanel's backgr "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
              Re: Can a jPanel's backgr "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
                Re: Can a jPanel's backgr "JT" <jt@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
                Re: Can a jPanel's backgr "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
            Re: Can a jPanel's backgr "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
          Re: Can a jPanel's backgr "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
        Re: Can a jPanel's backgr "JT" <jt@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
          Re: Can a jPanel's backgr "Philipp" <philipp@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000

csiph-web