Swing Repainting components after they are dragged back into view

In a Swing app, I have made a simple component with custom painting that I use as a TreeCellRenderer for non-leaf nodes in a JTree.

However, if you grab the whole app window and drag it so that the tree (or part of it) is off the side of your monitor, when it gets dragged back in, the painting is all screwed up.

I haven't been able to find an event that tells me when a component becomes unviewable like this and when it becomes reviewable. I'd like to be able to attach a listener to such an event and just force a repaint.

Or, if there's a better way, I'm up for that, too.

Any suggestions?
LVL 1
phavardelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Is it only when the window is moved *off* the screen and back again?
0
phavardelAuthor Commented:
Yes, only when the Jtree is moved off the screen and back. If only part of the Jtree is moved out there, only that part of the components gets mixed up.
0
phavardelAuthor Commented:
BTW, I'm developing for OSX and XP, and this seems to only happen on XP. Mac looks great.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

phavardelAuthor Commented:
Right now, so it doesn't irritate me, I have the scrollpane the tree is in listening for ancestorMoved, and repainting on that. But, that's a lot of unneccessary repainting.
0
phavardelAuthor Commented:
Alright, correction. It looked like it only happened moving it off the screen and back. It also seems to happen when part of the tree is obscured by another window (either another frame of the same program, or some other windows program). It happens when _part_ of the tree is obscured. If the entire tree is hidden, and then re-displayed (e.x. by clicking the program in the taskbar, or navigating back to it with alt+tab) all at once, it repaints.

The key seems to be that only _part_ of the tree is obscured.

Any ideas?
0
phavardelAuthor Commented:
Ugh, big stupid mistake.

I was requesting the clipping bounds, but painting as though that were the entire component size. Hence, the mix up, and why it worked when the entire component was hidden and then revealed.

Not sure why it was working on mac before, but, whatever.
0
GranModCommented:
Closed, 125 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.