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

Ads









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
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
TextFields
TextFields  How To create A details Of Student Using applet
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
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
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
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
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
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
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
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
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
swings question
swings question  how to change the background color with the help of color values by using swings
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
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
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
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 
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"><
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
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
JSP & Swings
JSP & Swings  How to integrate jsp and swings
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
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
java client server program for playing video file(stored in folder in the same workspace) using swings
java client server program for playing video file(stored in folder in the same workspace) using swings  Hello friends this is RAGHAVENDRA, I am doing a client server program to play a video file, when I run both client and server
java client server program for playing video file(stored in folder in the same workspace) using swings
java client server program for playing video file(stored in folder in the same workspace) using swings  Hello friends this is RAGHAVENDRA, I am doing a client server program to play a video file, when I run both client and server
java client server program for playing video file(stored in folder in the same workspace) using swings
java client server program for playing video file(stored in folder in the same workspace) using swings  Hello friends this is RAGHAVENDRA, I am doing a client server program to play a video file, when I run both client and server
java client server program for playing video file(stored in folder in the same workspace) using swings
java client server program for playing video file(stored in folder in the same workspace) using swings  Hello friends this is RAGHAVENDRA, I am doing a client server program to play a video file, when I run both client and server
Swings & JSP
Swings & JSP  Hai all, Can we use Swing components in a JSP?? Suppose if we enter details in a swing dialog box..and If we want the result in a JSP..is that possible??? Thank you
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
Swings and JDBC
Swings and JDBC  Hi.. I am vinay.. I am developing a small application using swings and mysql. I am sending part of the code here.. The problem is i need to update the mysql fields with values which are gettin from dynamiclly
swings
MAking combinitions
MAking combinitions  Dear All, Please help me.... I have some 60-70 lineswhich contains \new\code\R2.0.1\option.c \new\code\R2.0.3\option.c \new\code\R2.0.1\Test.c \new\code\R2.0.2\Test.c \new\code\R2.0.3\Test.c \new\code
how to create frame in swings
how to create frame in swings  how to create frame in swings
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 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
DYNAMIC BINDING
DYNAMIC BINDING  WHAT IS DYNAMIC BINDING
report making in asp
report making in asp  Hi sir, Please give some example report making code for jsp and mysql
DECESION MAKING STATEMENTS
DECESION MAKING STATEMENTS  The Decision Making statements may be implemented in different forms depending on the complexity of the condition to be tested. Describe various forms of decision making statements in java
Java making a method deprecated
Java making a method deprecated  java making a method deprecated In Java how to declare a method depricated? Is it correct to use depricated... to anyone who is using that method. Please tell me how to achieve that?  
Help in making a text formatter
Help in making a text formatter  I have a question on how to make a text formatter using Java. I attempted in doing so, but got a really low score on it, and so I'm having to rely on someone kind enough to help me. We use
making help window
making help window   how to make help window in gui with java
Business Intelligence for Decision Making
Business Intelligence for Decision Making  How do business intelligence helps in better decision making

Ads