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



Home Answers Viewqa Applet TextFields
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sureshkumar
TextFields
1 Answer(s)      3 years and 7 months ago
Posted in : Applet


How To create A details Of Student Using applet?


Advertisement
View Answers

April 5, 2011 at 3:04 PM


import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class  FormData{

    public static void main(String[] args){
    JFrame f=new JFrame();
    JLabel label1=new JLabel("Name: ");
    JLabel label2=new JLabel("Date Of Birth: ");
    JLabel label3=new JLabel("Address: ");
    JLabel label4=new JLabel("Contact No: ");
    final JTextField text1=new JTextField(20);
    final JTextField text2=new JTextField(20);
    final JTextField text3=new JTextField(20);
    final JTextField text4=new JTextField(20);
    JButton b=new JButton("Save");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        String v1=text1.getText();
        String v2=text2.getText();
        String v3=text3.getText();
        int v4=Integer.parseInt(text4.getText());

        try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into data(name,dateOfBirth,address,contactNo) values('"+v1+"','"+v2+"','"+v3+"',"+v4+")");
           JOptionPane.showMessageDialog(null,"Data is inserted successfully");
        }
        catch(Exception ex){
            System.out.println(ex);
        }
        }
    });
        JPanel p=new JPanel(new GridLayout(5,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(label3);
        p.add(text3);
        p.add(label4);
        p.add(text4);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}


Related Tutorials/Questions & Answers:
textfields and update - SQL
textfields and update  how can i retrieve a table from a database and put in on the textfields using jdbc?and at the same time update the items on the database
Advertisements
labels,textfields,buttons
labels,textfields,buttons  how to set the labels,textfields,buttons at certain positions such that we can add them without layout managers? my program is to design a login page with image and these labels at exact positions
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
textfields and update - SQL
textfields and update  how can i put retrieved table from a database to the textfields using jdbc?and at the same time update the items on the database..   Hello Friend As per ur 1st Q: Read the data from
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
Background color blocks all labels and textfields
Background color blocks all labels and textfields  I added background color but I dont see textfields and labels anymore, please help. What am I missing? (" JFrame f = new JFrame(); SchoolOption f1 = new SchoolOption(); Color c
Use Map to display file data into textfields
Use Map to display file data into textfields Collection framework allows... textfields which are generated at run time. In text file, we have written... = new JButton("Put file data into TextFields"); JPanel p = new JPanel
How to insert data from textfields into database using hibernate?
How to insert data from textfields into database using hibernate?  ...(); } This method doesn't work. I tried with quotes for textfields, without them. The setters require other parameters, not textfields. I tried to cast them
create a table in access2007 from gui application using textfields and combox
create a table in access2007 from gui application using textfields and combox  I want to create a table in ms access 2007 from gui application in which when i click create button the table should get created based on textfield
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)  how can i enter values in two different textfield's through 10 different buttons.?? as we saw a online calculator type
How to open textfields in the the same panel of the jframe by selcting from dropdown menu option ...
How to open textfields in the the same panel of the jframe by selcting from... and i have to show textfields and submit button on the basis of the selection... the textfields and submit button in the same panel of the jframe window . Below is my
Multiple Forms in JSP
Multiple Forms in JSP          The form tag creates a form for user input. A form can contain checkboxes, textfields, radio- buttons and many more. Forms are used
java swings - Java Beginners
java swings   Do you want to add textfields on the JPanel
compilation errors - Swing AWT
compilation errors  how to create a window with five textFields, five labels and three buttons
cp and sp
cp and sp  design a gui application to accept the cost price and selling price from the user in two textfields and then calculate the profit or loss occured
Java Program - JDBC
Java Program  A java program that display data in textfields and having buttons for move next, move previous,move last,move first using JFrame
data to the textfield by means of an actionListener - Java Beginners
data to the textfield by means of an actionListener  how can i put the data of the database 1 at a time to the textfields by means of an actionlisteners and can be view by next or previous
java programming
java programming  Hi friends i need simple login form coding using two labels,two textfields and two buttons in netbeans without using database connection. . if you know that logic please tell
creating a modal frame - Java Beginners
creating a modal frame  i have a JFrame with 2 textfields. i want that this frame should open in a modal mode. how to do this? please tell. thanks
java swings - Java Beginners
. Thanks, Valarmathi   Hi Friend, Do you want to add textfields on the JPanel? Thanks  Do you want to add textfields on the JPanel
hi
hi  sql date format is yyyy/mm/dd and user enter dd/mm/yyyy in textfields so when insert textfield value in sqldatabase table so how can convert date format so insert date store in sql table
place data in text fields from database using jdbc
place data in text fields from database using jdbc  i want get the data from database and place the records in the respective textfields using jdbc and swing like eno,ename,loc from emp table
database
database  Is it possible to let the user first type the database and table name in textfields and then provide him a taxt area to type an insert query to insert data in that table and then execute the query.....The project
swings
swings  Thank you deepak it is fine.... I think you have gone through mine sent code in that i am not able add that Textfield dynamically. Can youhelp me how can i add textfields dynamically in my code lookin forward to hear
using getText() to retrieve text from an array of text fields with loop.
using getText() to retrieve text from an array of text fields with loop.   hi, I have an array of about 50 textfields which show up when somebody presses button. Now I want to get the text from all the textfields using array
validating - Swing AWT
No TextField have to Contains only Numbers. Name TextFields have to contain only...;Hi Friend, Use the following code if you want to validate textfields TRollNo
Jdbc and Socket Program - JDBC
Jdbc and Socket Program  Sir, I would like to get a program i which first a Frame is created and then Username and pssword textfields are added to it.Then as we enetr the user name and password it should be updated
jsp - JSP-Servlet
jsp   how to write the jsp code to enable and disable the textfields based on the selection of drop down list elements  Hi Friend, Try the following code: function show(){ var op
Advertisements
 

 

 

DMCA.com