• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to fire event when JTable is resized?

 
Thomas Fly
Ranch Hand
Posts: 164
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After fooling around with custom table models for a while, I decided life would be made simpler by implementing the JTable using HTML tables for the cells- columns essentially are either left-justified or right-justified, with the widest entry centered within the column (just for fun, I also highlight the bad-duration-formats in pink).
However, this means that the html table cells should be rewritten if the app is resized horizontally. How do you hook into a resizing event?
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,
Man, you're really into pushing the edge of the envelope aren't you? Look at JViewport and JViewport.ViewListener which has a method: void componentResized(ComponentEvent e). That should give you a starting point.
Hope this helps,
Michael Morris
 
Thomas Fly
Ranch Hand
Posts: 164
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not the first person to make such an observation- it's amazing that I'm still living.
Table cells a.y.k. are just JLabels, which have no margin property. However I realized I could achieve a margin by using a 1pixel.gif icon and setting iconTextGap.
But then- since you need different margins for each column- it appeared I'd need a different custom class for each column...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic