Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes How to repaint/refresh/redraw JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to repaint/refresh/redraw JPanel" Watch "How to repaint/refresh/redraw JPanel" New topic

How to repaint/refresh/redraw JPanel

Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
Hi there,

To catch immediate attention, I have started New post

I want to redraw the JPanel (not graphics way)

my scenario is
I have two JButtons(jb1,jb2) and I am remove these two buttons and added new set of two buttons(jb3,jb4) upon Save action and I want to redisplay the JPanel with buttons(jb3,jb4)

please give me code specific and no theory please

Appreciate immediate help

..medival Man
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
It may be simpler to toggle the button's visibility:

[ February 02, 2006: Message edited by: Jeff Albertson ]

There is no emoticon for what I am feeling!
Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
First Of all, Thanx for immediate reply.
But, I need to place the buttons at same location. It seems given code sample will hide set of two buttons any time .

in laymans terms,

chang the name of Buttons name at the same position & location

-- appreciate help
here is code i am using where m_buttonPanel is JPanel and
m_previousButton -> Previous Button
m_nextButton -> Next Button,
m_cancelButton -> CancelButton
m_saveButton -> Save Button

and following code is action Handler


but repaint is not reloading the Jpanel but if change the focus of Screen and come back then it is displaying correctly
Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
i got it.

revalidate() will reload the components and visible
subject: How to repaint/refresh/redraw JPanel
It's not a secret anymore!