• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic