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

 
 


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

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 Pages:
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
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
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 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 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
Dynamic Proxies - Short Tutorial
Dynamic Proxies - Short Tutorial 2001-01-18 The Java Specialists' Newsletter [Issue 005] - Dynamic Proxies - Short Tutorial Author: Dr. Christoph G.... Welcome to our fifth "The Java(tm) Specialists' Newsletter", published
add
How to add two int numbers in Java Example  How to add two int numbers in Java Example  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
add
How to add two numbers in Java  add two number   Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main(String[] args
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 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 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
Dynamic keyword
during the run-time. Just add the magic keyword dynamic to the class definition: dynamic class Product{ var name:String; } Now let?s add dynamically two...Dynamic keyword  hi....... What is the dynamic keyword used
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I have some problems creating a page to add items into a cart. The page loads dynamic products from a database, and i would like to know how to group this products
Object Adapter based on Dynamic Proxy,java,Dynamic Object Adapter using Dynamic Proxies,newsletter,tutorial
, specifically on how to use dynamic proxies in Java to autogenerate code... The Java Specialists' Newsletter [Issue 108] - Object Adapter based on Dynamic Proxy... work with JDK 1.3. Here is how I would use the dynamic object adapter
JavaScript generate dynamic row
JavaScript generate dynamic row In this section, you will learn how to generate dynamic row using JavaScript. Here a row contain 3 fields(2 textfields,1 text area). Every time if the user click add button, a new row will get added
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
Generic Types with Dynamic Decorators - Java Tutorials
Generic Types with Dynamic Decorators 2001-10-24 The Java Specialists...' Newsletter", in which we look at how we can apply the dynamic decorators to produce.... How could we improve our situation by abusing dynamic proxies
Bulk insert and dynamic schema loading
on query. So how to load schema and create table dynamically? Which the best way...Bulk insert and dynamic schema loading  Hi All, I am new to H2 database and java. I have started working on these from past 1 month. I needs some
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  
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 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 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 Array iPhone
Dynamic Array iPhone  Dynamic Array iPhone How can i add NSMutable array dynamically into my iPhone App
how to add a file in GZIP
how to add a file in GZIP  Hi, how to add a file in GZIP using Java.   Hi, I have found a good referral site for How to Add a file in GZIP file format using Java. http://www.roseindia.net/java/examples/io
Create dynamic page through JSP
how to create dynamic page. This code shows one by one record of student from... Create dynamic page through JSP... database student; Then create a table named 'stu_info' in the same
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 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 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
add
Java Example to add two numbers  Java Example to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
add
Java Program to add two numbers  Java Program to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
How to change the data in the table dynamically ?
How to change the data in the table dynamically ?  This is my code. I want to add a sort button in the page and if i select any sort option then the data displayed in the table below should get sorted dynamically in this jsp page
add
add two no in Java  Java Add Example that accepts two integer from the user and find their sum  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
How to add two calendars on the same html page
How to add two calendars on the same html page  I have used the same.... Rest of the code remains same. <html> <head> <title>Java...;/a> </form> <!-- Calender Script --> <table id
uiscrollview add images
uiscrollview add images  How to add dynamic images to UIScrollView
Java Dynamic Array - Java Beginners
Java Dynamic Array  Hi everyone, I have two String arrays, lets say: static String[] locations={"Greece", "Germany", "Italy"}; static String..., School, Hospital), (Germany, University, School, Hospital), ... And if I add
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
add new package java
add new package java  How to add new package in Java
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
add
example that accepts two integer from the user and find their sum  example that accepts two integer from the user and find their sum  Here is a java example that accepts two integer from the user and find their sum
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
Adding checkbox in table using that delete table rows
Adding checkbox in table using that delete table rows  I need coding for how to add checkbox in table,the table data from database.Using... the selected rows using swing in java
Dynamic link in JSP
stuck with this LINK ...How to generate this dynamic link n all? I have tried...Dynamic link in JSP  Hii everyone...I have stuck from last 2 days... selecting One source and multiple Targets, i have to generate one table using

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.