• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

customizing a JTable

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking for code examples which customize JTables in different ways. Is there any sites which has some examples like this?
Thanks,
Frank
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I did manage to find this site which has alot of useful JTable examples.
http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
Have fun,
Frank
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still looking for an example which will demonstrates how to have rows that are automattically sized. Basically In my table I will have some cells which are multilined. I need all the text in this cell to be viewable, so each row quite possibly will have a different row height. How can this be done? Just think of the table which shows your new messages in Microsoft Outlook and you will understand what I am trying to achieve.
Thanks,
Frank
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the examples that discuss setting the cell renderers. I did something similar by setting the cell renderer to a text area. Then you can iterate through the columns of that row asking the renderer for the size it would be and get the one with the largest height to set the rowHeight. For this to work you also have to set the column widths (another iteration of using some "reasonable" value or the column header width, whichever was larger) so the text area knows how to wrap. Sorry I don't have anything online to show you - I got all of this from the Java Swing forum and from a book: graphic Java 2 - Mastering the JFC by Geary (the Swing volume). Hope this makes sense enough to help!
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Michelle,
I also encountered the same kinda problem. I tried doing what you said, but some if i have a small text the row height for that row is very large. And if i have a long text in my text area cell renderer then i the text in that cell is not showing up as multiline but only shows a part of the text in a single line, though the height is set as previous cell. I am kinda confused if my logic is any different.
Could you send me some code snippets regarding this like the cell renderer code and the iteration code.
really appreciate it,
Thanks
Jay
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic