Crush_40 Crush_40 - 1 year ago 227
Java Question

Radio Buttons in netbeans

I have a simple question?

how do i save an option from a radio button into a table of a database after hit the save button?

i'm using netbeans ide and an sqlite3 database with sqlite studio.

Answer Source

First get the value of your RadioButton, for Radio button there only two choices TRUE mean selected, FALSE mean not selected, so you will get true or false like that:

RadioButton rd = new RadioButton();
boolean value = rd.isSelected();

Second just persiste this value in database.

String requete = "INSERT INTO mytable(valueOfMyradioButton) values(?)";

statement = connection.prepareStatement(requete);

statement.setString(1, value);

Good luck.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download