making of dynamic textfields using swings

making of dynamic textfields using swings

How to make dynamic textfields using java swings

View Answers

March 2, 2011 at 11:18 AM

Java Swing Dynamic TextFields

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class DynamicTextFields
{
    public static void main(String[] args) 
    {
        JFrame frame=new JFrame();
        JButton b=new JButton("Add");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery("select * from data where id=1");
            String name="",address="";
            if(rs.next()){
                name=rs.getString("name");
                address=rs.getString("address");
            }
             JFrame f=new JFrame();
             f.setLayout(null);
             JLabel lab1=new JLabel("Name");
             JTextField text1=new JTextField(20);
             JLabel lab2=new JLabel("Address");
             JTextField text2=new JTextField(20);
             lab1.setBounds(10,10,100,20);
             text1.setBounds(120,10,100,20);
             lab2.setBounds(10,40,100,20);
             text2.setBounds(120,40,100,20);
             text1.setText(name);
             text2.setText(address);
             f.add(lab1);
             f.add(text1);
             f.add(lab2);
             f.add(text2);
             f.setSize(300,100);
             f.setVisible(true);
                }
                catch(Exception ex){}
            }
        });
        frame.add(b);
        frame.pack();
        frame.setVisible(true);
    }
}









Related Tutorials/Questions & Answers:
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
Advertisements
dynamic textfields
dynamic textfields  Hi, I am a fresher and joined recently in one company. they gave me a desktop application project using swings.here is my... textfield should be added to the screen.so please help.currently i am using
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
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
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
TextFields
TextFields  How To create A details Of Student Using applet
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
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
Dynamic tree using textarea data
Dynamic tree using textarea data  I need to create a dynamic tree by using text area data(words) as child nodes in struts. Any body please help me. "very urgent". thanks in advance
Making 301 redirection by using <c:redirect>
Making 301 redirection by using   How can i set the status as 301 when using tag? When i use , I am able to redirect to the desired URL (here, Google page) but I get 302 as the status of redirect. I need this status as 301. Any
want a program for date picker by using java swings
program by using swings..please help me thank you in advance.   Have...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
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I... into Database using hibernate. At first i use serialization. But i want my application... some browser conflict so now i am using upload bean. But all i cant do is upload
plz help me to write a snake game using swings - Swing AWT
plz help me to write a snake game using swings  write snake game program using swings
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
java swings - Java Beginners
java swings   Do you want to add textfields on the JPanel
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
making a web application using Web-Logic Server - Struts
making a web application using Web-Logic Server  Hello , I am a beginner to the java platform so i am facing some problem in making a web aplication using a struts framework.Hence i referred the docs given in the link http
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check , which is being accessed inside main function by two objects of Tst1 and Test2
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
swings
swings  i have a string1 it contains 3 parts,for example "123456 service hello" and string2 contains text "change request " like this. and the string3 should contain "123456 +(second string) hello" "second string can be dynamic
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 is create a table and enter the integer values during run time......I have
How to put the logo in login form using swings/awt?
How to put the logo in login form using swings/awt?  Hi, How to put the logo in login form using swings/awt? I write the login form is working but i want to put the logo in login form plz help   Here is an example
How to set the border in header and footer from login page using swings/awt
How to set the border in header and footer from login page using swings/awt  Hi, How to set the border in header and footer from login page using swings/awt
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
How to insert dynamic textbox values into database using Java?
How to insert dynamic textbox values into database using Java?  Hi I am trying to insert dynamic textbox values to database, my jsp form have 2... of dynamic textboxes with Name and Address will display....Now I want to Insert
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  Im doing virtual on screen keyboard as my project. i didnt get the method to performthe backspace and space operation using swings in java.can please help me  Hi
swings
swings  how to disable the labels.i am using the setenable(false) method to disable the label, but still mouse events(mouse clicked) are working on that label, how can i deactivate the mouse events also on the label
Making Tab using Javascript
Making Tab using Javascript       This Example describes the way to make Tab using javascript and css.For this we are going to make program named 
swings question
swings question  how to change the background color with the help of color values by using 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
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
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
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... using for dynamic row generation. <script LANGUAGE="JavaScript"><
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  sir thanks a lot for ur reply for my last question, can u please send me the entire project code of virtual on screen keyboard.i did but im not sure as it was right
Dynamic loading of Combo box list using servlet - JSP-Servlet
Dynamic loading of Combo box list using servlet  I have the category..., retrive it in a servlet, By using this value communicate to the data base...; Hi friend, dynamic bombobox in servlet
Which one is better for creating a GUI using swings either Manual coding or IDE(NetBeans,eclipse)..? drag and dropping components
Which one is better for creating a GUI using swings either Manual coding or IDE... in java application developing.... Which one is better for creating a GUI using swings either Manual coding or IDE(NetBeans,eclipse)..? drag and dropping components
How to find the size of a dynamic webpage using java... eg : Youtube........
How to find the size of a dynamic webpage using java... eg : Youtube........  package newpack; import java.io.BufferedInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL
Techniques used for Generating Dynamic Content Using Java Servlets.
Techniques used for Generating Dynamic Content Common Gateway Interface... with Web Server, using CGI program you can't accomplish... applications that generates dynamic pages. Microsoft has
swings header
swings header   have a string1 it contains 3 parts,for example "123456 service hello" and string2 contains text "change request " like... be dynamic data whatever we give from string2,that should be displayed on the screen
JSP & Swings
JSP & Swings  How to integrate jsp and swings
how to do dynamic ally placeholder using properties or some else - JSP-Servlet
how to do dynamic ally placeholder using properties or some else   dear sir, how to use and declare a dynamic place holder in java? i have to send the following mail Dear [Column 1] Your Bonus is [column 2]. Thanks
software making
software making   software hello sir sir i have learned this language, c and c++. when we doing coding in c and c++. that time we run those...++. please you give me guidness about making software. sir you tell me its
swings for webnms
swings for webnms  if i am expanding node of jtree then i want to collapse previous expanding node of jtree in swings how is it possible
software making
software making    hello sir , sir you post me answer its difficult to make software in c and c++. but sir i want to make software in c and c++.sir i regueast you please you guid me. i hope you will help me make
making call
making call  Hi, Is it possible to make a call from application with out quitting application in iOS 4?   hello,ADS_TO_REPLACE_1 this the code for call to a number NSString *phoneStr = [[NSString alloc

Ads