how to store data in table using swings

how to store data in table using swings

View Answers

July 27, 2009 at 10:37 AM

Hi Friend,

Try the following code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame
{
JButton ADD;
JPanel panel;
JLabel label1,label2,label3,label4,label5;
final JTextField text1,text2,text3,text4,text5;
Form(){
label1 = new JLabel();
label1.setText("UserID:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("First Name:");
text2 = new JTextField(20);

label3 = new JLabel();
label3.setText("Last Name:");
text3 = new JTextField(20);

label4 = new JLabel();
label4.setText("ADDRESS:");
text4 = new JTextField(20);

label5 = new JLabel();
label5.setText("Email:");
text5 = new JTextField(20);

ADD=new JButton("ADD");

panel=new JPanel(new GridLayout(6,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(label5);
panel.add(text5);
panel.add(ADD);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String value3=text3.getText();
String value4=text4.getText();
String value5=text5.getText();
Object rowData[][] = { { value1, value2,value3,value4, value5} };
Object columnNames[] = { "User Id", "First Name", "Last Name","Address","Email" };
JFrame f=new JFrame();
JTable table = new JTable(rowData,columnNames);
JScrollPane scrollPane = new JScrollPane(table);
JPanel p=new JPanel();
p.add(scrollPane);
f.add(p);
f.setVisible(true);
f.setDefaultLookAndFeelDecorated(true);
f.setSize(400,200);
}
});
}
}
class FormDemo
{
public static void main(String arg[])
{
try
{
Form frame=new Form();
frame.setSize(300,300);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}

Thanks

June 7, 2011 at 6:11 PM

i have created a form in java using Jbutton, jframe, concept..(CODE IS DOWN) in which user need to enter username, date, time, location etc.. now i want that the data which is entered to be in a file form.. How can i do it???

this is my code

import java.awt.*;
import java.awt.event.*;

public class DataEntry {
  public static void main(String[] args) {
  Frame frm=new Frame("DataEntry frame");
  Label lbl = new Label("Please fill this blank:");
  frm.add(lbl);
  frm.setSize(350,200);
  frm.setVisible(true);
  frm.addWindowListener(new WindowAdapter(){
  public void windowClosing(WindowEvent e){
  System.exit(0);
  }
  });
  Panel p = new Panel();
  Panel p1 = new Panel();
  Label jFirstName = new Label("First Name");
  TextField lFirstName = new TextField(20);
  Label jLastName =new Label("Last Name");
  TextField lLastName=new TextField(20);
  p.setLayout(new GridLayout(3,1));
  p.add(jFirstName);
  p.add(lFirstName);
  p.add(jLastName);
  p.add(lLastName);
  Button Submit=new Button("Submit");
  p.add(Submit);
  p1.add(p);
  frm.add(p1,BorderLayout.NORTH);
  }
}

output is a form .. what next??









Related Tutorials/Questions & Answers:
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... will be same to store data into tables) of my application....can any body give an example
how to store data in other table using servlet and jsp
how to store data in other table using servlet and jsp  pls can anyone tell how to store data in other table using servlet and jsp and want to display that data too.and the data in first table must be same.pls help
Advertisements
how to enter matrix data into a table of swings - Java Beginners
how to enter matrix data into a table of swings   Hi frends, I want to display a matrix data into a particular table...... Actually if the user... and insert the data into that table using swings...........matrix can be anything
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 can we store the encrypted passwaord in swings?
how can we store the encrypted passwaord in swings?   how can we store the encrypted passwaord in swings
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page  I have made a form in JSP having emp id, projectname and emp name.I want to store data related to employee in xml
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... the secified table. rs = statement.executeQuery(QueryString); </code>
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
How to Store Image using JSF
How to Store Image using JSF  Hi How to upload images in db. using..... But this code haven't option to upload any images . i want to store image in db..."); String qry = "insert into application_table(name,image)values('"+ uname
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i... the data when clicked on save button.. how can i do
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
Hi how to transfer table data from html page to excel sheet by using javascript .
Hi how to transfer table data from html page to excel sheet by using javascript .  html page to excel sheet by using javascript and i dont want to transfer all rows in table, i want to hide some rows in excel sheet. Please send
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
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
Beans in Swings table
Beans in Swings table  Hi Sir/Madam.... I am Trying Develop an Swing from which include an table which displays the data from mysql table and i am... ); } } catch(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane
how to store data in a text file - Java Beginners
how to store data in a text file  Hi friends, I want to know, how we can save the data in a .txt file using swings....... for example, i want... to retrieve the data....is it possible using swings...........can any one help me
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i... the data when clicked on save button.. how can i do this   The given
How to store values in a database using JSTL? - JSP-Servlet
How to store values in a database using JSTL?  I want to store values in a database... How can i store in database? Here is my code... This wil extract details and displays in a table format... Now i want to store these values
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name... for each user to store their details.. so pls help me how to create individual
How to change the data in the table dynamically ?
How to change the data in the table dynamically ?  This is my code. I... then the data displayed in the table below should get sorted dynamically in this jsp page... datastore = DatastoreServiceFactory.getDatastoreService(); Query q = new Query
How To Store Image Into MySQL Using Java
How To Store Image Into MySQL Using Java In this section we will discuss about how to store an image into the database using Java and MySQL. This example... you about how to store image into database using Java. We will use the MySQL
Insert Data in Table Using Stored Procedure
Insert Data in Table Using Stored Procedure ... data into a table using stored procedure. Steps: 1.Create database... Your data has been inserted into table. Download the source code
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data...   Hi, The insert into query is used to insert the data into MySQL table. Suppose we have a table: CREATE TABLE email ( first_name varchar(20
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
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
filter and display html table data using ajax - Ajax
filter and display html table data using ajax  Hi i am stuck up... to DisplayCategory.jsp i want to display the data retrieved from the session in a 2d array on DisplayCategory.jsp in the form of the html table using responseText. how to do
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
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
sorting and filtering the displayed table data using jsp and xml
sorting and filtering the displayed table data using jsp and xml  I... the content of xml file in web page. Now I would like to sort and filter those data that is displayed in web page. How to do it ??? Please help as soon as possible
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
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 you will Show all data from a table.
How you will Show all data from a table.   How you will Show all data from a table.   Hi, following query is used to show all the data of the table-ADS_TO_REPLACE_1 SELECT * FROM tablename; Thanks
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
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail
Retrieving Data from the table using PreparedStatement
Retrieving Data from the table using PreparedStatement... to fetch the data from the database in the table from our java program using... by using the executeQuery() method of the PreparedStatement object. Now the data
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML... HELP ME OUT WITH HOW TO VIEW THE STORED DATA IN XML FILE USING EMPNAME. PLEASE
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
how to store and retrieve image using struts2 and hibernate integration
how to store and retrieve image using struts2 and hibernate integration  how to store and retrieve image using struts2 and hibernate integration? plz help !! thanks in advance
how to store JTree data hierarchically in mysql database from netbeans
how to store JTree data hierarchically in mysql database from netbeans  how to store JTree data hierarchically in mysql database from netbeans. I am new to this topics so I need a program and tables you are using in database
please send me the banking data base in swings
please send me the banking data base in swings  sir, please send me how to create the banking data base program in swings
How to read excel data and store it in database - Java Beginners
How to read excel data and store it in database  Hi, I want a java code to read data from excel and store it in Ms Access database.I tried the code but but its printing the output in console.I dont know how to store the excel
how to store image in oracle express edition using servlet
how to store image in oracle express edition using servlet  strong text how to store image in oracle express edition using servlet?   Please visit the following link: Servlet Insert image into MySQL database
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser

Ads