Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Help with setting the JTable rows to resize to the size of the file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help with setting the JTable rows to resize to the size of the file" Watch "Help with setting the JTable rows to resize to the size of the file" New topic
Author

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

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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

Joined: Oct 29, 2001
Posts: 8935
    
    9

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with setting the JTable rows to resize to the size of the file