Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems updating gui in JApplet

 
Marte J.
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

MyApplet
________________________________

TreePanel
_____________________________

Result
___________________________________
 
Marte J.
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
found the error:
I need to use
_treeScroll.getViewPort().add(_tree);
and
_treeScroll.getViewPort().remove(_tree);
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Applets
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic