• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable Columns width

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to everyone,

I want to make the width of columns in JTable according to the width of biggest cell. But for this I think I need to read almost all the record set. It will definately slow down the processing speed so its not looking me a good solution.

Another solution that I am thinking is to extend the length of heading titles (array of field names) by filling it with space, accroding to database schema and then adjust the the column width according to these headers. But in some cases column width may be unnecessarialy wide.

I would like to know your opinion to get a better solution.

Thanks! in Advance
Best Regards!
Tahir
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tahir,

My advice: don't make your life harder if it's not needed, so just don't do it. All my columns are distributed evenly in the available space and the CSR (user) can resize them if he wants.

Maybe another possibility is to use percentages to make certain columns a bit bigger than others. It can be easily done and won't slow down the processing. For some example code, click here.

Hope it was helpful.
Kind regards,
Roel
 
Tahir Abbas
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Roel

Its very easy to just display data in JTAble, no need to go beyond the requirements and ofcourse if I'll use Swing in future then I'll use IDE.

This time my JTable shows Field Names and an extra column Serial Number. All columns have equal width, as default. Table displays all screen wide. I didn't apply any TableModel or any other option. Do you think its enough because it fulfills the requirement "Result must be in JTable".

Or What formatting do you think I should apply. There are 100 Marks for General Consideration.

Best Regards!
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tahir,

My JTable was pretty straightforward: columns distributed evenly, used custom table model, single selection, auto resize of all columns and that's it. I think decisions concerning the JTable don't affect the general considerations score section, rather the gui one.

Kind regards,
Roel

 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic