wonders in java

i have 1 JFrame, on that added 2 JPanel. When i click Button on 1st panel it adds Picture to the second panel. But it never displays the picture automatically, while i am restore the JFrame it displays the picture. Even i used repaint() on first panel.

i m wondering, while starting program the paintComponent called automatically. When i try to call repaint() explicitly i never works.

Can any one tell me which i have to repaint (JFrame, 1st panel or second panel)

Regards

Jeyanthi

[514 byte] By [Jeyanthia] at [2007-11-27 6:17:50]
# 1
This might help youframe.validate();frame.repaint();
BuggyVBa at 2007-7-12 17:31:10 > top of Java-index,Java Essentials,Java Programming...
# 2
I hope its second panel, since u want to display image in second panel.
b.m.krajua at 2007-7-12 17:31:10 > top of Java-index,Java Essentials,Java Programming...
# 3

> have 1 JFrame, on that added 2 JPanel. When i click Button on 1st panel it adds Picture to the second panel. But it never displays the picture automatically, while i am restore the JFrame it displays the picture. Even i used repaint() on first panel.

you need to call repaint on second panel not on first.

>i m wondering, while starting program the paintComponent called automatically.

paintComponent called every gui need to displayed or re-displayed to screen, eg. when your frame show up first or resize.

if you only want to display an image, it will much easier to using image icon instead of overiding a panel.

j_shadinataa at 2007-7-12 17:31:10 > top of Java-index,Java Essentials,Java Programming...
# 4
Why dont you try invalidate()? panel2.invalidate()
AnanSmritia at 2007-7-12 17:31:10 > top of Java-index,Java Essentials,Java Programming...