• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to fire event when JTable is resized?

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic