File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to repaint/refresh/redraw JPanel

 
Nageswar Kakolla
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be simpler to toggle the button's visibility:

[ February 02, 2006: Message edited by: Jeff Albertson ]
 
Nageswar Kakolla
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

m_buttonPanel.remove(m_previousButton);
m_buttonPanel.remove(m_nextButton);
m_buttonPanel.add(m_cancelButton);
m_buttonPanel.add(m_saveButton);
m_buttonPanel.repaint();


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
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got it.

revalidate() will reload the components and visible
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic