File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

customizing a JTable

 
Frank Hale
Ranch Hand
Posts: 230
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Michelle Baxter
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Jay Shaw
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic