Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you refresh a panel - Need Help

 
bobby, morkos
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following:
Frame application which contains:
SplitPanel JPanel
HeaderPanel JPanel
ButtonPanel JPanel
SplitPanel JPanel contains:
TextPanel JPanel
TreePanel JPanel
TextPanel JPanel contains:
OperationPanel JPanel
infoPanel JPanel
On a tree event, how do I refresh infoPanel, to display new information. I use a constructor that takes a parameter like:
OperationPanel(treeEvent) and the information is correctly send to my Operational JPanel. But, it does not want to refresh.
I tried UpdateUI() AND repaint. Nothing works. Please, somoene help?
 
Julia Reynolds
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try setting the panel to visible(false)and back to visible(true). I had a weird refresh bug that was fixed that way.
Julia
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had similar problems and I found that altering the size of a component by 1 pixel and then resetting it worked. But I didn't like that so I investigated and found a class called RepaintManager.
Once you get the RepaintManager for your component you have a method
markCompletelyDirty( JComponent c )
Using this you label the component for a complete repaint once the events currently being handled are dealt with. This was quick enough for my application but if you try to do it in the middle of a long operation it will have to wait until the operation is completed.
Hope that helps,
 
Andy Peter
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used to have similar problems and seemed like resizing was fixing it. I later found out that it wasn't resizing but it was the underlying validate() or pack() code taht was fixing the issue. I was adding Checboxes dynamically to a panel and was having such an issue.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the observer design pattern?
Check out java.util.Observable and java.util.Observer.
Make the tree an observable and make the panels implement observers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic