This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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 Introducing JavaFX 8 Programming this week in the JavaFX 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

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="" 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...
Don't get me started about those stupid light bulbs.
subject: How to fire event when JTable is resized?
It's not a secret anymore!