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.
Andrew Thompson - 19 Nov 2005 15:40 GMT
> I have an application where entering certain numbers changes the data
> held, I had observers looking at these observables and when they are
[quoted text clipped - 3 lines]
> 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>

Signature
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.
Thomas G. Marshall - 19 Nov 2005 20:05 GMT
paulobrad@gmail.com 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
[quoted text clipped - 3 lines]
> 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().

Signature
Sometimes life just sucks and then you live.