Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: buttons and buttongroups send values to database

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: buttons and buttongroups send values to database

    ok thanks, ill try that. database connectivity was not an issue btw.

Similar Threads

  1. Replies: 1
    Last Post: January 31st, 2013, 04:55 AM
  2. retrieve data from database using Hashmap (multiple values in one key)
    By ashin12 in forum Collections and Generics
    Replies: 2
    Last Post: April 4th, 2012, 05:22 AM
  3. [SOLVED] compare form values with database values
    By VaniRathna in forum Java Servlet
    Replies: 2
    Last Post: October 24th, 2011, 02:48 AM
  4. Using jbutton to write to jtextfield values to database
    By Sociopath in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 23rd, 2011, 10:53 PM
  5. Replies: 0
    Last Post: April 15th, 2010, 05:13 AM