buttons and buttongroups send values to database
hi. forgive me if this had been asked before. if so please direct me to that topic.
i have a registration form in java to mysql. for the gender radiobuttons i created a buttongroup. now i want to send the values of which is selected to the database. if anyone can be kind enough to tell me what to do by atleast giving the syntax for the "if this button is selected do this action" code in the database
TIA
Re: buttons and buttongroups send values to database
The GUI code and the database code shouldn't be in the same class and should be completely decoupled. Look into 1) getting information from the ButtonGroup, and then a separate issue 2) how to update your database with this or any information. A full answer for number 2) is beyond the scope of this forum I think, since it would require writing a full tutorial and then some. As for number one, you can get the selected JRadioButton from a ButtonGroup by calling its getSelection() method which returns the ButtonModel of the selected JRadioButton. If you've given your radio buttons proper ActionCommand Strings you can then call getActionCommand() on the ButtonModel object (after first checking that its not null), and find out the selected JRadioButton that way.
Re: buttons and buttongroups send values to database
ok thanks, ill try that. database connectivity was not an issue btw.