TextFields

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









Related Tutorials/Questions & Answers:
TextFields
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
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
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... { JButton b = new JButton("Put file data into TextFields"); JPanel p = new
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
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
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 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
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
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 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
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
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
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
Swings - JDBC
Swings  Hi..Sir...I am begginer in Netbeans... How to retrieve the databases from sqlserver to Jtable in Netbeans... In my form..i have three fields like..Number,Name,PhoneNo(3 Labels & 3 textfields),(Save)1 button & Jtable
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
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
struts2 - Framework
those come in two differnet rows(lines).....i need one jsp with two textfields
jsp help - JSP-Servlet
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
java run time textfield and use with map - Java Beginners
java run time textfield and use with map  i want to program which read data from file and store in map and display in different textfields which...) throws Exception { JButton b=new JButton("Put file data into TextFields
Swing and AWT Problem - Swing AWT
containing three textfields CODE: String a=TNa.getText().toString(); String b...; } } so i want to send those three textfields values to the next frame...); how can i get those textfields values to these three String variable
java swing - Swing AWT
("")))){ label.setText("Please enter the textfields."); } else{ try{ Class.forName
Container or Component - Java Beginners
,RootPane etc are containers and Table,Button,TextFields etc are components
htmlcode - Java Interview Questions
htmlcode   I have two textFields. One TextField have all country names,if we select one country name then the related states of that countries are displayed in another textfield dynamically.How is it possible. pls send
Struts Warnings ...About FormBeanConfig & about Cancel Forward - Struts
labels & Textfields & 2 buttons save & cancels. 3)success.jsp Displays message
Servlet-JSP population - JSP-Servlet
with textfields also. how the loop in the servlet should go to check all the boxes
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

Ads