Crush_40 Crush_40 - 3 months ago 14x
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.


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.