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



Home Answers Viewqa Java-Beginners java code using swings
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


chandana
java code using swings
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


code that should be able to enter data of student details using all swings into the access database using jdbc connectivity


Advertisement
View Answers

July 23, 2011 at 10:37 AM


import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class  FormData{
    public static void main(String[] args){
    Frame f=new Frame();
    Label label1=new Label("Emp No: ");
    Label label2=new Label("Emp Name: ");
    Label label3=new Label("Salary: ");
    final TextField text1=new TextField(20);
    final TextField text2=new TextField(20);
    final TextField text3=new TextField(20);
    Button b=new Button("Save");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        int v1=Integer.parseInt(text1.getText());
        String v2=text2.getText();
        int v3=Integer.parseInt(text3.getText());
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           String sql = "insert into emp(EMP_NO,EMP_NAME,SALARY) values(?,?,?) ";
           PreparedStatement pst = con.prepareStatement(sql);

            pst.setInt(1, v1);
            pst.setString(2, v2);
            pst.setInt(3,v3);
            pst.executeUpdate();
           JOptionPane.showMessageDialog(null,"Data is inserted successfully");
        }
        catch(Exception ex){
            System.out.println(ex);
        }
        }
    });
        Panel p=new Panel(new GridLayout(5,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(label3);
        p.add(text3);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}


Related Tutorials/Questions & Answers:
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
want a program for date picker by using java swings
want a program for date picker by using java swings  to write a program for the date picker by using java swings.any one please help me by providing the code to this java date picker by using the java swings.previously a program
Advertisements
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
An application using swings and vector methods
An application using swings and vector methods   Hi, I want an application in Java swings which uses good selection of Vectors methods
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
how can i draw a table using applet or swings - Java Beginners
how can i draw a table using applet or swings  Hi RoseIndia, Actually, I was trying for creating a table using applet or swings.......... My task... Mohammed Afsar  Hi Friend, Try the following code: import java.awt.
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  Im doing... backspace and space operation using swings in java.can please help me  Hi Friend, Try the following code: import java.util.*; import java.awt.
Java Swings
Java Swings  I am doing one project on java Swings, in this i have created one jframe where i defined some JButtons and Jcombobox's, here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently
java swings - Java Beginners
java swings   Hi, I need the code for click the refresh button then list values will be refresh.Please send the code ........... Thanks, Valarmathi
how to store data in table using swings - Java Beginners
how to store data in table using swings  Hi, I am doing a project in which i need to store some data in the table using swings.......Iam using... , whether do i have any option in swings to increase my output look (my target
java swings - Java Beginners
java swings   Do you want to add textfields on the JPanel
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  sir thanks... project code of virtual on screen keyboard.i did but im not sure as it was right or not  Hi Friend, Please send your code. Thanks
java swings - Swing AWT
java swings  I am doing a project for my company. I need a to show the performance of the employees by using bar bharts. Please give me how can we write the code for bar charts using java swings.  Hi friend, I am
java swings
java swings  Hi, I have one class file using three panel methods,the three methods is used for three tabs.then how can i set the background image.Please send the sample code for me. I already posted two questions,but i didnt get
java swings - Java Beginners
java swings   Hi, I need the code for joptionpane with jcombobox. my requirement is click on add button,one joptionpane will come.from the option pane i need to select the combobox values. Please send the sample code
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
java code using while loop
java code using while loop  
java code for PartialSearch using Map????
java code for PartialSearch using Map????  java code for Partial Search using Map
java swings
java swings  Hi, I need a sample code for once click the exit tab the frame window will be closed. Instead of button close i need tab close option.Please send the sample code immediately.......?Its very urgent........ Thanks
java swings
java swings  Hi, I need the sample code for how to set the background image using jframe and also set the jtext field and jlable boxes under the bachground image. Please send the code immediately,its very urgent.Please send me
java swings
java swings  hi... I am having multiple swing forms.. when i click on a button another form is going to opening but it is opening as different form... Now i want it to be open dynamically instead separately.... Is there any
java swings
java swings  how can we use the shared locks of dbms in java? I am working on a mini project which is based on the eamcet councilling .i am struck with a problem where if a student select a college and a branch and sees
java swings - Java Beginners
java swings   Hi, I already posted the question for three times.... I have two listboxes.If i select first value in the first listbox and moved... code............. jboss.mq:service
java swings - Java Beginners
java swings   Hi, I have two classes(two tabbed panes). how can i... the code as sson as possible. Thanks, Valarmathi  Hi Friend, Try the following code: 1)ClassA.java import java.awt.event.*; 2
about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir...: http://www.roseindia.net/java/example/java/swing/ Hope
java swings - Java Beginners
java swings   Hi , I have two listboxes.I want to move one listbox value into another listbox using add button. I have the code....Please check... correct the value and send it to me. This is my java code package
java swings - Java Beginners
java swings  Hi, I have two listboxes .Move the one listbox value into another listbox using add button.Move the value one by one into another listbox.Please give the code using jpanel. Thanks, Valarmathi
swings - Java Beginners
for this in google, but i got very difficult programs. i am beginner in java swings . i want... Friend, Try the following code: import java.awt.*; import javax.swing....); } } For more information, visit the following link: http://www.roseindia.net/java
java swings - Java Beginners
java swings   Hi, This is my code. How can i set the jtextfield...", Font.BOLD, 12)); javapathname = new JLabel("Java Path"); javatextpath = new JTextField(33); javatextpath.setToolTipText("Java Installation Path
 

 

 

DMCA.com