wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes setting up the size of a JTable to the size of a vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting up the size of a JTable to the size of a vector" Watch "setting up the size of a JTable to the size of a vector" New topic
Author

setting up the size of a JTable to the size of a vector

clare summers
Greenhorn

Joined: Feb 19, 2003
Posts: 3
Hi
I want to read in a file when the focus is lost behind JTextfield1 and when i read in this file i want to be able to set up the JTable to the size of the vector.
Could anyone help please?
thanks
C
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Clare,
The easiest way is to create a two dimensional array from your vector and then create a new JTable using the following constructor.

However a better method would be to extend the TabelModel.
If you need an example let me know!
Jason.
clare summers
Greenhorn

Joined: Feb 19, 2003
Posts: 3
Hi jason
Thanks for the reply
Yes could you please give me an example
Thanks
c
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Clare,
I've modified a AbstractTableModel that I've used for reading a variable length CSV file.
You need to create an instance of the model and then pass the model in the JTable constructor.
e.g



Hope it helps!
Jason.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting up the size of a JTable to the size of a vector
 
Similar Threads
how can i pull out every number from a vector
How can I add rows in a Jtable
How can I find out how many lines there are?
help with a statement
count how many tokens are in the first line