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
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!
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: