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


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

Re: Accessing Swing compo

From "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this>
Subject Re: Accessing Swing compo
Message-ID <ereod5$hou$2@south.jnrs.ja.net> (permalink)
Newsgroups comp.lang.java.gui
References <ft4Ch.11899$xJ6.9212@newsfe14.lga>
Date 2011-04-27 15:30 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Knute Johnson wrote:

> Do methods that don't modify Swing components have to be called from the 
> EDT?  Methods such as JTextField.getText(), JCheckBox.isSelected() etc.
> 
> Thanks,
> 

I would say not. 

What happens behind the scenes when a JCheckBox is selected? Can you be sure
that your thread requesting the state won't interfere in some subtle and
unpredictable way with the EDT if that thread is changing the check box
selected state because the user has just clicked on it?

How about if you call getText() whilst the user is entering text into your
JTextField?

You may be able to constrain your GUI operation to a limited set of
circumstances in which it works, and is ok. But, to me, that would just be a
bug waiting to happen.

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    nmw@ion.le.ac.uk 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

---
 * 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 | Find similar


Thread

Accessing Swing component "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
  Re: Accessing Swing compo "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
  Re: Accessing Swing compo "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000

csiph-web