How to add dynamic table in java

How to add dynamic table in java

How to add dynamic table in java

View Answers

March 16, 2012 at 11:53 AM

import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;

public class JTableDatabase {
public static void main(String[] args) {
Vector columnNames = new Vector();
Vector data = new Vector();
JPanel p=new JPanel();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
String sql = "Select * from data";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement( md.getColumnName(i) );
}
while (rs.next()) {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++){
row.addElement( rs.getObject(i) );
}
data.addElement( row );
}
rs.close();
stmt.close();
}
catch(Exception e){
System.out.println(e);
}
JTable table = new JTable(data, columnNames);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
col = table.getColumnModel().getColumn(i);
col.setMaxWidth(250);
}
JScrollPane scrollPane = new JScrollPane( table );
p.add( scrollPane );
JFrame f=new JFrame();
f.add(p);
f.setSize(600,400);
f.setVisible(true);
}
}









Related Tutorials/Questions & Answers:
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java...(); } catch(Exception e){ System.out.println(e); } JTable table = new JTable(data...); } JScrollPane scrollPane = new JScrollPane( table ); p.add( scrollPane ); JFrame f=new
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
Advertisements
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project... a dynamic table for every company.but whenever i'm inserting values to the company... student table. and company and year value i'm getting through company table.but apache
How to add a column in a table
How to add a column in a table   ... should know how you can modify the structure of the table. The problem is that we have to add a new column to our database by using the java program
Dynamic table in jsp
Dynamic table in jsp  Hi..... I have a java file to read excel file... to show all values of excel file on jsp page in a table format. All elements are displaying on jsp page but in vertical line. How can i change them in table
how to add components (like button , checkbox etc) in a table column in core java
how to add components (like button , checkbox etc) in a table column in core java  plz tell me how to add components(like button, checkbox, radiobutton etc)in a table column in core java
how to add the calendar to the dynamic rows in html or jsp page - JSP-Servlet
how to add the calendar to the dynamic rows in html or jsp page  ...,no and i have 2 button in my jsp page ADD and delete button. when i click on add... can save the 2 or more row values at a time but i need to add the calenadar
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need... files but i done create and update for a single table. i dono how to automate
How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet
Dynamic table data to Excel in JSP
Dynamic table data to Excel in JSP   Iam trying to export dynamic...() { document.form1.des.disabled=0; } function view_Table() { } function...;div align="center"><br> <table width="500" height="300
How to add radio button value in a table for particular field?
How to add radio button value in a table for particular field?  Hi,I have a jsp form in which one static field for date and below a dynamic table... dynamically from other table and two radio button one for present and the second
How to add a column with checkboxes for each record in my table in JSP
How to add a column with checkboxes for each record in my table in JSP   Hi, Could you please explain it to me how I can add a column with check boxes for each record in my table in JSP? Also, I want to figure out a way
how to make JTable to add delete and update sql database table
how to make JTable to add delete and update sql database table  Hello all I want to know how to make JTable to act actively to add delete and update database table. i am struck ed here from long time please help me
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 textboxes...Name, Address with an add button, if you click add button new set
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have a label in which instead of passing text i have inserted image using
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have a label in which instead of passing text i have inserted image using
JavaScript add row to table
JavaScript add row to table       This section illustrates you how to add a new row to the existing... will get the table containing the columns Name and Address and a button 'Add row
mysql alter table add column
mysql alter table add column  Hi, What is the syntax of mysql alter table add column? Thanks   Hi, Here is mysql alter table add column example: ALTER TABLE employee ADD address VARCHAR(50); Read more at MySQL Add
How to create dynamic array in C?
How to create dynamic array in C?  How to create dynamic array in c programming language?   Dynamic Array in C Tutorial
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
How to Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
How to add BigDecimal in Java?
How to add BigDecimal in Java?  Hi, I have two BigDecimal variables. I want to add these two values. How to add BigDecimal in Java? Thanks   Hello, I will show you how you can add two BigDecimal? Suppose you 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
JavaScript add row dynamically to table
to add row to a table dynamically then we can also do this with the JavaScript code. In this example we will describe you how to add row dynamically to the table... JavaScript add row dynamically to table  
dynamic retrivel of data from mysql database in table format at jsp
dynamic retrivel of data from mysql database in table format at jsp  ... the data from database and display it as table format in jsp... For example, i have... and also details of each member should be displayed in the table format in jsp
jsp code for dynamic time table generation - JSP-Servlet
jsp code for dynamic time table generation  hi I am doing my academic project college automation. I want to generate time table dynamically for each btech and mca,mba branches.Pls provide a solution how to process
Dynamic retrieval od data from database and display it in the table at jsp
Dynamic retrieval od data from database and display it in the table at jsp ... it in table. <%@page language="java"%> <%@page import="java.sql.*"%>... the details of 20 members in a table format at jsp page by dynamically retrieving
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...... Please help... Thanks, Ramit   the above code is running on JAVA
mysql alter table add unique constraint
mysql alter table add unique constraint  How to add mysql alter table add unique constraint in mysql table. Thanks   Hi Following query query can be used: ALTER TABLE mytable ADD CONSTRAINT uc_key1 UNIQUE
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 draw a table on jframe in java - Java Beginners
how to draw a table on jframe in java  how to draw a table on jframe in java?  Hi friend, import java.awt.*; import...", "MCA" } }; Object headers[] = { "Upper", "Lower" }; JTable table
SQL Alter Table Add Multiple Columns
SQL Alter Table Add Multiple Columns       Alter Table Add Multiple Columns in SQL modifies the table and add columns to the existing table. Understand
alter table add foreign key mysql
alter table add foreign key mysql  Hi, How to add foreign key in mysql using the query 'alter table add foreign key mysql' Thanks   Hi, We can use the following query: ALTER TABLE emp_address ADD FOREIGN KEY (emp_id
Delete and add row from Table View iPhone
Delete and add row from Table View iPhone In this tutorial will learn how to delete and also how to add row into the table view iPhone, with the help of edit... and shows how to create and manage table views in your own projects. It starts
mysql alter table add multiple columns
mysql alter table add multiple columns  Hi, I have a table in database. I want to add multiple columns into existing table. What is the code for mysql alter table add multiple columns? Thanks   Hi, You can use
SQL Alter Table Add Multiple Columns
SQL Alter Table Add Multiple Columns       Alter Table Add Multiple Columns in SQL modifies the table and add columns to the existing table. Understand
Dynamic polymorphism - Java Beginners
Dynamic polymorphism  Develop with suitable hierarchy, classes for point, shape, rectangele, square, circle,ellipse, triangle, polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.. Thanks
Dynamic Polymorphism - Java Beginners
Dynamic Polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.? Thanks
how to use stringtokenizer on table? and display in table format.
how to use stringtokenizer on table? and display in table format.  table is retrieved from mysql database and each row contains data like(java,c,c++,.net
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
table in java
table in java  Could any one make compiler in java please reply me
table in java
table in java  Could any one make compiler in java please reply me
table in java
table in java  Could any one make compiler in java please reply me
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
java with jsp and dynamic database retrival for bar charts
java with jsp and dynamic database retrival for bar charts  Hi, I am having a table name tablelogin,it consists of columns userid,logintime,sessionid,ip_address,logout. so,can any one help me out how to get the bar chart
table in java
table in java  please l want to make table and insert by user
how to use stringtokenizer on table? and display in table format.
display result in row format  how to use stringtokenizer on table? and display in table format
how to create a table
how to create a table  create table tablename (name varchar(10),name.... Use the following query: create table tablename (name varchar(10),address varchar(10)); For more information, visit the following link: Java Create
How to add key value pair in Java
How to add key value pair in Java  Hi, I have to store the key and value pair in Java. How to store key value pair in Java? Thanks   Hi... Table. Thanks

Ads