How to use Radio Button in Java Tutorial using NetBeans IDE

This tutorial is all about How to use Radio Button in Java Tutorial using NetBeans IDE, you will learn how to insert a value in database using radio button.

Radio Button is very useful when it comes to data registration, because radio button can be use in a field of gender or sex.

It will help you identify if that person is a he or she. This tutorial uses radio button and NetBeans IDE.

Please follow all the steps below to complete this tutorial.

How to use Radio Button in Java Tutorial using NetBeans IDE?

  1. The first step is to create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. After creating a project, the default form will be created automatically.
  2. And now the next step is to drag two radio buttons in this example I use radio button based on gender.
  3. After dragging the two radio button rename it as Male and the other one is Female.
  4. And then go to your code and create a gender variable, after creating the variable go to your gui and double click each radio button. Like for example when you double click the male radio button you will assign a value to a gender variable to gender=” Male” otherwise its gender=” Female”

[java]

try {

String sql = "INSERT INTO users (first name, last name, gender) VALUES (?,?,?)";

pst = conn.prepareStatement(sql);

pst.setString(1, fnameTxt.getText());

pst.setString(2, lnameTxt.getText());

pst.setString(3, gender);

pst.execute();

JOptionPane.showMessageDialog(null, "User has been added!");

}catch(Exception e){

JOptionPane.showMessageDialog(null , e);

}

[/java]

Then you’re done. Run your project and see if it works.

About How to use Radio Button In Java

Project Name:How to use Radio Button
Language/s Used:JAVA
Database:None
Type:Desktop Application
Developer:IT SOURCECODE
Updates:0
How to use Radio Button In Java– Project Information

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]

Facebook: facebook.com/RyyanSalem

Contact No.: +639098911050

Related topic(s) that you make like:

Leave a Comment