aspose file tools*
The moose likes Java in General and the fly likes How do you refresh a panel - Need Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do you refresh a panel - Need Help" Watch "How do you refresh a panel - Need Help" New topic
Author

How do you refresh a panel - Need Help

bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
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

Joined: May 31, 2001
Posts: 123
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

Joined: May 30, 2001
Posts: 328
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,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Andy Peter
Greenhorn

Joined: Feb 12, 2002
Posts: 12
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

Joined: Nov 22, 2008
Posts: 18944
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do you refresh a panel - Need Help