Home Answers Viewqa Java-Beginners How to save Selected text of RadioButton in to Access Databse

 
 


sushant
How to save Selected text of RadioButton in to Access Databse
1 Answer(s)      3 years and 2 months ago
Posted in : Java Beginners

Sir I wnt To store Selected JRadioButton Text in to access Database
plz Help Me Sir.
and how to link website in to our Java Application with JRadioButton.
View Answers

March 20, 2010 at 11:38 AM


Hi Friend,

To insert JRadioButton text, you need to create a textfield which should be invisible on the frame. This textfield will get the selected radio button value using ActionListener.

Here is the code:

import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SwingFrame{
JTextField text;

public static void main(String[] args) throws Exception{
SwingFrame sf=new SwingFrame();
}
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("Name");
final JTextField jt1=new JTextField(15);
JLabel lbl2 = new JLabel("Gender");
text=new JTextField(15);
final JRadioButton Male,Female;
ButtonGroup radioGroup=new ButtonGroup();
Male=new JRadioButton("Male");
radioGroup.add(Male);
Female=new JRadioButton("Female");
radioGroup.add(Female);
JButton button=new JButton("Submit");
text=new JTextField(15);
Male.addActionListener(al);
Female.addActionListener(al);
lbl1.setBounds(50,50,70,30);
lbl2.setBounds(50,90,70,30);

button.setBounds(50,130,100,30);
jt1.setBounds(110,50,100,30);
Male.setBounds(110,90,100,30);
Female.setBounds(210,90,100,30);
text.setBounds(110,130,100,30);
text.setVisible(false);

button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String name=jt1.getText();
String g=text.getText();

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("insert into names(name,gender) values(?,?)");
st.setString(1,name);
st.setString(2,g);
int i=st.executeUpdate();
JOptionPane.showMessageDialog(null,"Data is successfully inserted into database.");
}
catch(Exception ex){}
}
});

f.add(lbl1);
f.add(lbl2);

f.add(jt1);

f.add(Male);
f.add(Female);
f.add(button);
f.add(text);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
text.setText(((JRadioButton) e.getSource()).getText());
}
};
}









Related Pages:
How to save Selected text of RadioButton in to Access Databse - Java Beginners
How to save Selected text of RadioButton in to Access Databse  Sir I wnt To store Selected JRadioButton Text in to access Database plz Help Me Sir. and how to link website in to our Java Application with JRadioButton. 
selected radiobutton to display different page
selected radiobutton to display different page  there are three radio button are there , in that selected button to display different page. when submit it, using struts2 framework . plz help me to how write code
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try...:access","",""); Statement stmt=con.createStatement(); ResultSet rs
radiobutton
radiobutton  how to add radiobutton in combobox in java
RadioButton Control in Flex
text="Select any of the following RIA"/> <mx:RadioButton...RadioButton Control in Flex: The RadioButton control in Flex is a set... member of this group can be selected at a time. We can not select more than one
textfield selected text
textfield selected text  How to select text in text field
RadioButton in Flex4
RadioButton in Flex4: In Flex4 RadioButton is a spark component. You can use two or more RadioButton components with in a RadioButtonGroup and select only one RadioButton at one time and if one stands in selected mode then all
Save JRadioButton Text in to database - Java Beginners
Save JRadioButton Text in to database   Hello Sir I have Two JaradioButtons 1)Semwise Course 2)Yearwise Course I want To Save Text from JRadioBuuton in to Access Databse and Access Databse. with user can select any one
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem
Radiobutton in Xcode
Radiobutton in Xcode  I am new to Xcode .I want to implement Radiobutton in Xcode (using Objective C),and when i select any Radiobutton ,it should remain selected when i open my view next time. Is it possible anyway ? Any advise
radiobutton - JDBC
radiobutton  hi how do you insert a radiobutton into a table. eg: how to select army and put it into a column in JDBC. army is a part of the the group army navy air force
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]  HI team, This is Srinivas, and I have a query and i explained here... I have to save some datas in an MS ACCESS database file [*.mdb], after
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database  Hello Sir I want Store Corse Type that contains Two JRadioButton I want Store Information from JRadioButton to MS Access Database, and I
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL  <html> <head> <...("text/html;charset=UTF-8"); PrintWriter out = response.getWriter
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL  <html> <head> <...("text/html;charset=UTF-8"); PrintWriter out = response.getWriter
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.  I am using postgresql-8.4.4-1-windows as database, jboss-4.0.5.GA as server and jdk-6-windows-i586 with IDE
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend...:access","",""); Statement stmt=con.createStatement(); ResultSet rs
Java Swing: Validate radiobutton
Java Swing: Validate radiobutton In this tutorial, you will learn how... only one button can be selected at a time. Swing supports radio buttons... java.awt.event.*; public class RadioButtonValidation{ JTextField text
How to upload and save a file in a folder - Java Beginners
How to upload and save a file in a folder  Hi How to upload and save a file in a folder? for example Agreement.jsp File: So when... should be able to access the file. Can u please tell me the code..  
How to Display values from databse into table
How to Display values from databse into table  I want to display values from database into table based on condition in query, how to display...;b>Authors Name</b></td> <td>: <input type="text" name
Javascript get Date And Selected Option Text
to get the selected option text and displayed in Javascript. This tutorial explains you that how to display the date and the selected option text in Javascript...Javascript get Date And Selected Option Text In this tutorial we will learn
save uiimage to photo library
save uiimage to photo library  How to saved the clicked picture... or not The given code is the second step "How to save or write a clicked picture...; Save UIImage to photo library Creating a camera application in iPhone need
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  .... & how to connect tht form to my databse , so it can store data?   1... into databse, which can later be seen by admin only...or can be used for retrievel
Connect J ComboBox with Databse - Java Beginners
Access Database with JComboBox , when I Select any Item from Jcombobox Related...:odbc:access","",""); Statement stmt=con.createStatement(); ResultSet rs... private String selectedString(ItemSelectable is) { Object selected
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.  how to dynamically add text boxes with add and remove link based on drop down choices, if a particular
how to save an input to jsp page in a text file?ave an input given b
how to save an input to jsp page in a text file?ave an input given b  how to save the input given by the user in jsp page to a text file
How to save run time created text-file on a disk using jsp/servlet?
How to save run time created text-file on a disk using jsp/servlet?  I have a JSP page with save button.In that I created the file(e.g a.txt) at run-time,when I click on the save button,it will ask where to save the file
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am... to skip all the text fields shapes and all the button from the frame.. but all the values of text fields and levels should be there.. please send me any
Java JComboBox Get Selected Item Value
how to get the selected item value form JComboBox. javax.swing.JComboBox.... In this tutorial we are discussing about how to store the selected item value... to follow some following steps : How to create MS Access Database Run MS
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to connect two databse through HibernateFramework
how to connect two databse through HibernateFramework  how to connect two databse through HibernateFramework
save text file - Java Beginners
save text file  hi i have just start programming in java.please guide me if i want to read a text file in java.then the text file is save in which directory
Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option
. Display JavaScript dropdown selected value
. Display JavaScript dropdown selected value  How to get the selected...;head> <title></title> <script type="text/javascript">...("dropdown").value; alert("You selected : " + dropdownValue); } <
java code using combobox,radiobutton,checkbox
java code using combobox,radiobutton,checkbox  hi, send me java code for entering student details into ms access database, the code should includes combo box,radiobutton and checkboxes pl send as early as possible
ID using get the databse latest value and displayed in jsp
ID using get the databse latest value and displayed in jsp   I have some text box like name address city ,I have submit button and preview button... in the form (it means latest values) ... how to retrive that values using ID
How to save image after edit in php
How to save image after edit in php  Hello, I have create a simple... successfully but i don't know how to replace orignal image with the effects. please...;script src="pixastic.core.js" type="text/javascript"></script> <script
save output in multiple text files
save output in multiple text files  Hi..I'm getting problem to store the output of this php code into multiple text files. Can anyone sugeest. Here is my code: <?php for($i=1; $i<=100; $i++) { $html = file_get
How to make a border shine text effect, make a border shine text effect, border shine text effect
How to make a border shine text effect   ... border of the text, It is very simple by this example. New File: Create a new document. Write text: Take new layer and give name "
do not repeat values in databse during insertion using php and javascript
do not repeat values in databse during insertion using php and javascript ... to accomplish throgh program. how to give this validation ? db.php $connect..., $query); form.jsp <html> <head> <script type="text
how to insert data from netbeans into databse
how to insert data from netbeans into databse  how to insert data from netbeans into databse   Please visit the following link: http://www.roseindia.net/webservices/web-services-database.shtml
how to know which jList is selected and according to that fetch the value
how to know which jList is selected and according to that fetch the value ... rows of databse with employee id as primary key) How to know which jList is selected so that i get the value of employee_id from the correct jList (i.e which
.csv file to databse
this values to database table in correct coloumn using java or jsp. how can i do
how to access element added via javascript dynamically using jsp code
how to access element added via javascript dynamically using jsp code  Urgent..Anyone please Assist how to access data from the elements added via..."); element1.type = "text"; element1.value=""; cell1.appendChild

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.