The moose likes Swing / AWT / SWT and the fly likes panel - repaint(); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "panel - repaint();" Watch "panel - repaint();" New topic

panel - repaint();

Roldan Baldo
Ranch Hand

Joined: Aug 11, 2009
Posts: 99
i have a panel1 and panel2, panel2 is where the picture is displayed and i set to true the setDoubleBuffered,
and i have a button called "UP" and "DOWN", if I press DOWN the image will scaled down as what ive set it to.
and if I press UP it do the other way around,

the problem is sometimes when i press UP/DOWN the image wont resize, (or is it the panel that the action will not be performed),
and i will press again UP/DOWN, it resize again.
what could the problem?

i called this every time i pass a new image

this works fine for me, but it just dont repaint() i think sometimes.. any help would be appreciated..
pete stein

Joined: Feb 23, 2007
Posts: 1561
I gather that you are adding and removing components from a container. Do you revalidate the container after doing this? Are you sprinkling your code with println statements to check if code that should be called is being called and to check the state of critical fields at the time of the calls.

If my suggestion doesn't help, you may wish to create a small compilable program that is compilable and runnable by us and that demonstrates your problem.

Much luck!
Roldan Baldo
Ranch Hand

Joined: Aug 11, 2009
Posts: 99
yes it works well.


thank you very much.
I agree. Here's the link:
subject: panel - repaint();
It's not a secret anymore!