File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes dynamic jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "dynamic jtable" Watch "dynamic jtable" New topic
Author

dynamic jtable

Prahlad Joshi
Ranch Hand

Joined: Apr 21, 2007
Posts: 44
i want to create a table whose column and row names will be entered at run time by the user(and hence the size will depend on the number of strings entered by him).
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8434

The DefaultTableModel provides all the functionality you require.


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Ganesh Chinni
Greenhorn

Joined: Dec 30, 2005
Posts: 24
Just in case if you wanted a sample code to dynamically add rows to table,

DefaultTableModel model;
JTable table;

model = new DefaultTableModel();

model.addColumn("Name");
model.addColumn("Phone");

table=new JTable(model);

for(i=0;i<=5;i++) {
Object[] rowData = {"XYZ","1236"};
model.insertRow(i,rowData);
}


Regards,
Ganesh
SCJP
SCWCD
SCBCD
[ October 24, 2007: Message edited by: Ganesh Chinni ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic jtable
 
Similar Threads
Please Answer soon with explanation
Problem with window.prompt
How to find user put nothig in JTextField?
Form data loss
ActionError Problem