Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Refusing a user action on a redio button

Thread view: 
jcpmont@hotmail.com - 04 Jan 2004 17:14 GMT
Hello all,

I have a swing interface with radio buttons in a button group. I would
like to be notified if the user clicks on one of the buttons BEFORE
the action actually take place because under certain conditions I
could refuse the action. I guess one way would be to use a normal
actionlistener and then revert to selecting the original button if the
action is refused, but I would like to know if there is a way to do it
more cleanly.

Thanks
Jean-Claude
Brian Pipa - 04 Jan 2004 18:21 GMT
> Hello all,
>
[quoted text clipped - 5 lines]
> action is refused, but I would like to know if there is a way to do it
> more cleanly.

Why not disable the radio button(s) that shouldn't be selected at that
time and enable them when they can be selected?

Signature

---
MP3 Automagic CD Cover Creator
http://maccc.filenabber.com

jcpmont@hotmail.com - 04 Jan 2004 22:33 GMT
> Why not disable the radio button(s) that shouldn't be selected at that
> time and enable them when they can be selected?

Yes, it would be the logical thing to do but I have to deal with
legacy code
that prevents me from doing that easily. If the user clicks on the
radio button he/she will be asked a question and depending on the
answer the action will be accepted or ignored.
Brian Pipa - 05 Jan 2004 06:27 GMT
>>Why not disable the radio button(s) that shouldn't be selected at that
>>time and enable them when they can be selected?
[quoted text clipped - 4 lines]
> radio button he/she will be asked a question and depending on the
> answer the action will be accepted or ignored.

How about always save the last button clicked, then if one is clicked
and you "ignore" the click, reset the radio group to have the last valid
one selected?

some pseudocode:

int lastSelected;

actionPerformed(ActionEvent e){
    if (isSelectionValid()){
        lastSelected = currentSelection;
        doValidSelectionStuff();
    }
    else{
        setSelected(lastSelected)
    }

}

Signature

---
MP3 Automagic CD Cover Creator
http://maccc.filenabber.com

brougham5@yahoo.com - 06 Jan 2004 00:50 GMT
>that prevents me from doing that easily.

Easily?

I'd say that a consistent user experience should usually trump "easily"
solved.  Always exceptions of course, and you're the only one in a position
to judge.  I'd really try to find another solution so that you're not
reverting buttons after the question is asked.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.