aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to fire event when JTable is resized? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to fire event when JTable is resized?" Watch "How to fire event when JTable is resized?" New topic
Author

How to fire event when JTable is resized?

Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
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?


Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
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
 
subject: How to fire event when JTable is resized?