Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to add dynamic table in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Bhausaheb Sangale
How to add dynamic table in java
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


How to add dynamic table in java


Advertisement
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
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
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
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 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
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 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 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 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
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 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
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
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
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 date and change date in java - netbeans
how to add date and change date in java - netbeans  I need to code use to increase date How to get date after 30 days using netbeans
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 Add JComboBox on JPanel - Java Beginners
How to Add JComboBox on JPanel  How to Add JComboBox on JPanel D:\java>javac ViewElements.java ViewElements.java:181: expected...(){ JFrame f = new JFrame("Frame in Java Swing"); f.getContentPane().setLayout(null
How to add
How to add   Hi, I want to make a website which will recommend users books according to the genre selected by them. I am using PHP, JavaScript and mySQL. The problem is that there will me almost more than 100 books
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 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 Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
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  
How to add java bean in Java Application - Java Beginners
How to add java bean in Java Application  How can it be possible to plug a java bean into a target application like a frame window after creating and making the jar file. pabitra Guwahati.Assam  Hi Friend, Please
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
 

 

 

DMCA.com