repaint() but no changes until i minimise then maxamise?

P

paulobrad

I have an application where entering certain numbers changes the data
held, I had observers looking at these observables and when they are
notified they make changes to what is displayed on screen, one of these
is some swing graphics. I do a repaint() in the observer but when I run
the app nothing happens until i move the window of the screen and back
on again. Is there a way of getting it to actually re draw the window
so I can see the changes instantly?

Many thanks in advance.
 
A

Andrew Thompson

I have an application where entering certain numbers changes the data
held, I had observers looking at these observables and when they are
notified they make changes to what is displayed on screen, one of these
is some swing graphics. I do a repaint() in the observer but when I run
the app nothing happens until i move the window of the screen and back
on again. Is there a way of getting it to actually re draw the window
so I can see the changes instantly?

Yep, fix the code.
Many thanks in advance.

No worries.

BTW - c.l.j.gui is thataway..
<http://www.physci.org/codes/javafaq.jsp#cljg>
 
T

Thomas G. Marshall

(e-mail address removed) said something like:
I have an application where entering certain numbers changes the data
held, I had observers looking at these observables and when they are
notified they make changes to what is displayed on screen, one of these
is some swing graphics. I do a repaint() in the observer but when I run
the app nothing happens until i move the window of the screen and back
on again. Is there a way of getting it to actually re draw the window
so I can see the changes instantly?

Not sure. A few things.

1. Pare the problem down and post the code here. Make it *very* pared down.
Note that just doing this process will likely illuminate the problem.

2. repaint() only sets a flag to tell the updating mechanism to redraw when
it gets a chance. It does not fire off any call to paint() specifically.
This, among other things, allows us to not worry about calling repaint() too
quickly.

3. if what you're doing is layout driven, then there is an entire notion of
"validation". Google for validate(), and invalidate().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top