Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
clare summers
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi jason
Thanks for the reply
Yes could you please give me an example
Thanks
c
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic