Re: Accessing Swing component data



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@xxxxxxxxxxxx
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
.