how to lock a jcheckbox?

S

Scott Steiner

hi,

i have a jframe which has several jcheckboxes on it. when the user
clicks on a checkbox then some action happens which takes a couple of
seconds. during this action i set the mouse cursor to an hourglass.
unfortunately the user can click on other checkboxes during this action
while the mouse cursor is an hourglass. question: how can i lock all
other checkboxes during the action so that the user can't click on them
until the initial action has ended? disabling the other checkboxes isn't
good since this grays them out which i don't want.

thx!
 
U

Uwe Seimet

Scott said:
i have a jframe which has several jcheckboxes on it. when the user
clicks on a checkbox then some action happens which takes a couple of
seconds. during this action i set the mouse cursor to an hourglass.
unfortunately the user can click on other checkboxes during this action
while the mouse cursor is an hourglass. question: how can i lock all
other checkboxes during the action so that the user can't click on them
until the initial action has ended? disabling the other checkboxes isn't
good since this grays them out which i don't want.

From a user interface point of view, does a user expect a time-consuming
operation when he clicks on a checkbox? A checkbox may not be the right
GUI element to use in cases where clicking on it triggers such an operation.
On the other hand, if you use checkboxes and the user should not click
on them, then I think you should disable them (gray them out), because
that's the common method to signal that a GUI object cannot be selected
in the current context.
 
S

Scott Steiner

Uwe said:
From a user interface point of view, does a user expect a time-consuming
operation when he clicks on a checkbox?

it might take anywhere between 1 second and say 5 seconds, that depends
on the server response time
A checkbox may not be the right
GUI element to use in cases where clicking on it triggers such an operation.
[...]

i thought the checkbox should be best because it represents an on/off
state which is exactly what i'm trying to represent i.e the checkboxes
all represent settings which are either on or off
 
U

Uwe Seimet

Scott said:
it might take anywhere between 1 second and say 5 seconds, that depends
on the server response time

Do you ensure this maximum timespan with a timeout? I am just asking
because I have experienced situations where resolving a hostname takes
more than 5 seconds and where it took much more than 5 seconds before I
got a connection refused message from a server.
i thought the checkbox should be best because it represents an on/off
state which is exactly what i'm trying to represent i.e the checkboxes
all represent settings which are either on or off

I see. Why is there a problem with the user clicking on the other
checkboxes while an operation is in progress? Does it make sense to have
the operation running in the background (e.g. another thread), so that
you can properly react on other checkboxes being clicked on?

IMHO regardless of how a final solution may look like, I don't think
checkboxes that may not be clicked on should be enabled. They should
grayed out, invisible, whatever. Everything else is not compliant with
any GUI I know.
 
A

Andrew Thompson

Definitely don't have the checkbox invoke the action
itself, try something different..
Do you ensure this maximum timespan with a timeout? I am just asking
because I have experienced situations where resolving a hostname takes
more than 5 seconds and where it took much more than 5 seconds before I
got a connection refused message from a server.

....
IMHO regardless of how a final solution may look like, I don't think
checkboxes that may not be clicked on should be enabled.

That is a very good point, but if the user would best be
presented with a boolean element, there might be better,
more intuitive ways to update the UI and inform the user.
So..

Instead of invoking the refresh on checkbox state change, you
enable a *button* that reads 'Refresh Data' or 'Submit Query'
or ..whatever it takes to convince the user that a server
update is required to proceed.

Once the final set of changes has been made by the user
(tick this, untick that..) they click the 'Refresh Data'
button and at that moment you ..
a) freeze the state of the UI or
b) pop up a modal dialog/option pane to block input
and inform 'Processing'.

HTH
 
P

Pete Barrett

it might take anywhere between 1 second and say 5 seconds, that depends
on the server response time
A checkbox may not be the right
GUI element to use in cases where clicking on it triggers such an operation.
[...]

i thought the checkbox should be best because it represents an on/off
state which is exactly what i'm trying to represent i.e the checkboxes
all represent settings which are either on or off

What are you doing if the user wants to change 2 settings, and then
see the results? I don't know the details of your application, of
course, and that question may not make sense, but I had a similar
application recently (combo boxes instead of checkboxes, but the
principle was the same). What I did was to get the data in a separate
thread in response to changing the combobox selection, but to allow
the user to change one of the other comboboxes while the download was
going on. When that happened, the original download was cancelled
silently, and a new one started with the new settings.

Pete Barrett
 
R

Roedy Green

during this action i set the mouse cursor to an hourglass.
unfortunately the user can click on other checkboxes during this action
while the mouse cursor is an hourglass. question: how can i lock all
other checkboxes

setEnabled( false );
setEnabled( true );

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top