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



Home Answers Viewqa Java-Beginners Save JRadioButton Text in to database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shweta
Save JRadioButton Text in to database
1 Answer(s)      4 years and 8 months ago
Posted in : Java Beginners


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 option from that two RadioButtons.
plz Help Me Sir.

Advertisement
View Answers

March 24, 2010 at 10:39 AM


Hi Friend,

Try the following 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("Course");
text=new JTextField(15);
final JRadioButton c1,c2;
ButtonGroup radioGroup=new ButtonGroup();
c1=new JRadioButton("Semwise Course");
radioGroup.add(c1);
c2=new JRadioButton("Yearwise Course");
radioGroup.add(c2);
JButton button=new JButton("Submit");
text=new JTextField(15);
c1.addActionListener(al);
c2.addActionListener(al);
lbl1.setBounds(50,50,70,30);
button.setBounds(50,80,100,30);
c1.setBounds(110,50,200,30);
c2.setBounds(310,50,200,30);
text.setBounds(110,80,100,30);
text.setVisible(false);

button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if((c1.isSelected()==false)&&(c2.isSelected()==false)){
JOptionPane.showMessageDialog(null,"Please select radio button");
}
else{
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(ctype) values(?)");
st.setString(1,g);
int i=st.executeUpdate();
JOptionPane.showMessageDialog(null,"Data is successfully inserted into database.");
}
catch(Exception ex){}
}
}
});

f.add(lbl1);
f.add(c1);
f.add(c2);
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());
}
};
}

Thanks


Related Tutorials/Questions & Answers:
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... java.awt.*; import java.awt.event.*; public class SwingFrame{ JTextField text
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... JRadioButton I want Store Information from JRadioButton to MS Access Database, and I want Select any One JRadioButton At a Time out of Two. plz Give Me Code Sir
Advertisements
Problem with JRadioButton and Access Database - Java Beginners
Problem with JRadioButton and Access Database  Hello sir ,Here I have write following code to save text on JradioButton but this is not saved in Access Databse, I want to store course type in to database and also other fields
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
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
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...; Hi Friend, To insert JRadioButton text, you need to create a textfield
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 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
SQL database parameters should save at where?
SQL database parameters should save at where?  Hi, Currently... the script will be running for very long time, I like to move the SQL database..., if there is a database changed (hostname, username or password) It should
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use...; Now i want to store it on database... Please help me Thanks in Advance
how to import excel sheet into mysql database and save it as a table in database
how to import excel sheet into mysql database and save it as a table in database  sir, i want to import an excel sheet into a MySQL database and after importing it i want to store the excel sheet as a table in database
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database.... Apache Tomcat/6.0.29  We have used MySQl database. 1)page.jsp: <
code save word file in 10g database - SQL
code save word file in 10g database  I am not having any idea to save the whole word document in Oracle 10g. Please help me.   Hi Friend, Try the following code: import java.io.*; import java.sql.*; public
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add a student System.out.print("Enter student ID: "); int ID = scan.nextInt(); System.out.print("Enter your name: "); String name = scan.next(); break
uploading a text file into a database
uploading a text file into a database  how to upload a text file into a database using jchooser   import java.io.*; import java.sql....: "); final JTextField text=new JTextField(20); JButton b1=new JButton
i want to save image on server folder. and i want to save URL of this folder and name of image in database
i want to save image on server folder. and i want to save URL of this folder and name of image in database  hi i want to save image on server folder. and i want to save URL of this folder and name of image in database.on click
How save,get picture from database in my jsp page?
How save,get picture from database in my jsp page?  How i save picture in db after browsing it,and also how i get it on my other jsp page
what is proper way to save pictures in SQl database and call it through JSP ?
what is proper way to save pictures in SQl database and call it through JSP... 'getContextPath()' mehtod using this method I can call pictures and Text on same... type i can't see text on same page. Please tell me proper way to do
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai, this is my jsp where i have enter multiple username and password and save it to database in single hit user.jsp <form action="UserServlet" method="post
How to save form fields into the MySql Database without submit button in jsp?
How to save form fields into the MySql Database without submit button in jsp?  I want to store user inputs into the database using javasccript or ajax or jqury but without submit button. Form Contains three fields
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi All, I am new to java and i need to upload excel sheet to mysql, please suggest me the steps to do this, i am able to connect to the database, from there i don't
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 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
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
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 the following code: import java.sql.*; import javax.swing.*; import
Java save file to database
Java save file to database In this section, you will learn how to insert file to database. Description of code: Firstly, we need to establish a connection between MySql database and java file with the help of various types of APIs
Question about "Insert text file data into Database"
Question about "Insert text file data into Database"  Hey I was reading the tutorial "Insert text file data into Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
Advertisements
 

 

 

DMCA.com