Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with setting the JTable rows to resize to the size of the file

 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I need some help with my code. I am using visual age for Java to construct the Gui but have come to a stop now as i'm having trouble.
The problem that I have is I want to be able to set the ampunt of rows in my JTable to the size of the file, so if the file has 50 lines going down I want the JTable rows to resize to 50.
My code so far, when you click on the browse button the JFilechooser pane shows up. I then read in my file that I want to read in. in this case it is a csv file, but that is as far as I have got.
The Jtable rows do not resize to the size of the file.
so could someone please be so kind as to direct me in the right direction or even adjust my code to how it should be
Thanks
Ben
 
Joe Ess
Bartender
Pie
Posts: 9257
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just invoke setNumRows() on the JTable's data model (invoke JTable.getModel() to get the TableModel, then cast it to DefaultTableModel). You should look at How to use Tables in the Java Tutorial since you will probably want to add and edit data in the JTable as well.
 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Joe,
Thanks for the reply,
That is what i'm having trouble with getting the JTable rows to resize to 8 (the size of the file, I have looked at the link you gave me but I am still having great difficultied with this, could you please help me with the code?
Thanks Again
Ben
[ January 27, 2004: Message edited by: ben riches ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic