• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Paul Bradley
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that you are using an IDE of some sort, put a System.out.println right before the repaint executes to make sure that your repaint is getting called first. I have a hunch that it may not be.
 
nabi bux
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You donotdescribe problem so sound
but i have some hint try to use them
use revalidite() function instead of
repain
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree with C Clites; the System.out.println("Calling thisThatOrTheOtherMethod()"); call is a very useful aid to debugging.

You don't say much about your problem; where exactly is your repaint() call? Is it in the sam place as the call to alter the numbers, viz inside your actionPerformed() method?
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . And what have you got in your paintComponent() method? It ought to start with super.paintComponent(g); as its first statement, otherwise you get the old appearance with the new appearance superimposed.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and I never noticed it is your 1st post.

Welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!