TextFields

Ads
 

TextFields

How To create A details Of Student Using applet?

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();
    }
}

Ads









Related Tutorials/Questions & Answers:
TextFields
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
Advertisements
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
dynamic textfields
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
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
Add color to background but I can't labels or textfields
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
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 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
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
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
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
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
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
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
Java scroll pane-java GUI
field... 30 rows are there...30 textfields r also there.. Take Situation
java gui-with jscroll pane
field... 30 rows are there...30 textfields r also there.. EndUser is entering
java gui-with jscroll pane
field... 30 rows are there...30 textfields r also there.. EndUser is entering
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized  import java.awt.*; import java.awt.event.*; import java.applet.*; public class Textfields extends Applet implements
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
submit button should show the user various textfields on the same panel from
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
submit button should show the user various textfields on the same panel from
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
submit button should show the user various textfields on the same panel from
hi!
for ma project...note that its made by using tools lik textfields , button etc
Java Queries
the textfields, button and labels on the frame using setBounds() method. import
search from database
textfields... please help the above code id of insert but i tried with select
Java Swing Create XML file
swing components and display it in xml file. We have created textfields... and fetch all the data from textfields and create an xml file with proper

Ads