Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


sushant
How to save Selected text of RadioButton in to Access Databse
1 Answer(s)      4 years and 6 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.

Advertisement
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 Tutorials/Questions & Answers:
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. 
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
Advertisements
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 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
radiobutton
radiobutton  how to add radiobutton in combobox in java
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
textfield selected text
textfield selected text  How to select text in text field
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
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 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 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 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
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 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 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
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
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
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 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 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
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
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
How to save value in JSP
How to save value in JSP  Employee Name Time-IN Time-OUT... 324 2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes
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
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
How to Connect J ComboBox with Databse - Java Beginners
How to Connect J ComboBox with Databse  How to Connect J ComboBox with Databse  Hi Friend, Do you want to get JComboBox values from database?Please clarify this. Thanks
How to Access MS Access in jar.
How to Access MS Access in jar.  how do i access my Ms-Access file... to access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to access a Ms-access via JDBC but cant find the file wen
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
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i
How to save image on the server by applet
How to save image on the server by applet  HI, in my project I am... If user want to export this chart as GIF format then this chart should be save as a gif image on the server directory. Can any Body help me how can I do it Thanks
How to save image on the server by applet
How to save image on the server by applet  HI, in my project I am... If user want to export this chart as GIF format then this chart should be save as a gif image on the server directory. Can any Body help me how can I do it Thanks
how to get the image of a selected JRadioButton to another panel?
how to get the image of a selected JRadioButton to another panel?  how to get the image of a selected JRadioButton to another panel
how to create a bar chart in jsp by fetching value from oracle databse?
how to create a bar chart in jsp by fetching value from oracle databse?  i want to show the population of various states in a bar chart in my jsp page by fetching the data from my oracle table. i am using my eclipse as my IDE
How to save data - Swing AWT
How to save data  Hi, I have a problem about how to save data ,but first before data save to dababase, data must view in jLisit or Jtable... save data from jList and Jtable(in jList or jTable data will be many).Thank's
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
how to by default chceckbox button is selected in struts
how to by default chceckbox button is selected in struts   i want to by default checkbox is selected please help me.. my is follwing <%@taglib... i want to all rows are by default selected
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records... of worker name within d combo box and display that id into a text box. plz answer me this q. urgently. With Regards, Vishwnath
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records... of worker name within d combo box and display that id into a text box. plz answer me this q. urgently. With Regards, Vishwnath
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... of worker name within d combo box and display that id into a text box. plz answer me this q. urgently. With Regards, Vishwnath
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... of worker name within d combo box and display that id into a text box. plz answer me this q. urgently. With Regards, Vishwnath
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... of worker name within d combo box and display that id into a text box. plz answer me this q. urgently. With Regards, Vishwnath
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
how to display selected checkboxes dynamically using jsp
how to display selected checkboxes dynamically using jsp  Hi friends i have a requirement that : in my JSP page i have radio buttons...) is available in DB,the respective radio button should be selected automatically
How to access Subclass?
How to access Subclass?  How to access subclass in java? please tell me the syntex with an example
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
 

 

 

DMCA.com