Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getGraphics() returns null, while paintComponent is also problematic.

801912Dec 19 2008 — edited Dec 22 2008
I have the following table that generates tooltips and produces a popup when a row is clicked. I need to use FontMetrics in the renderer to see if the text is truncated and only then produce the tooltip. I'm facing a problem where this.getGraphics() returns null and therefore doesn't initialize fontMetrics. One way to reproduce this it to click on the table, have the popup generated, minimize it and move your mouse back to the table. I also read other postings here and used paintComponent, as they suggested (commented out). paintComponent seems to mess up the display of table contents.I was wondering if anyone knows a work around for this? Thanks in advance for your help.
P.S. Yes, this is the only forum I've posted this question in.

OK, I think I need to post the code in a reply thread to this. I seem to extend 5000 characters and have been working on shrinking the text for about 15 minutes! I'll post the code in the next thread. Funny, I never had this problem before.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2009
Added on Dec 19 2008
13 comments
830 views