This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Applets and the fly likes Problems updating gui in JApplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Problems updating gui in JApplet" Watch "Problems updating gui in JApplet" New topic

Problems updating gui in JApplet

Marte J.

Joined: Dec 03, 2003
Posts: 2
I have a JApplet with a JPanel with another JPanel � TreePanel � containing a JScrollPane with a JTree.
When init() is run in MyApplet, _treePanel is initiated with a JTree, with test data hardcoded in TreePanel�s constructor. I want the tree to change every time a thread loops, by calling method _treePanel.updateResultTree(root) from the thread, with a new root. To test this, I have hardcoded a new tree content in the thread to pass to the TreePanel. In method updateResultTree(root), I remove the existing JTree from JScrollPane and add a new JTree to it, with the new root. Then I repaint the JScrollPane.
When I run the applet, the initial tree is displayed, but it is not updated with the new JTree for the first thread loop as expected. How is the gui in a JApplet refreshed/updated?? Will SwingWoker update the gui automatically without forcing repaint()?
Please help! Thanks in advance!



Marte J.

Joined: Dec 03, 2003
Posts: 2
found the error:
I need to use
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Moving to Applets

Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
I agree. Here's the link:
subject: Problems updating gui in JApplet
It's not a secret anymore!