• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A JTree with JProgressBar's for its nodes

 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

GUI code is not my forte as you'll probably be able to tell, essentially I want to have what I've described in the title. I came across this stackoverflow answer http://stackoverflow.com/questions/7036036/adding-multiple-jprogressbar-to-tablecolumn-of-jtable/7036206#7036206 which is specific to a JTable.

I have butchered this and spent quite some time trying to do essentially the same thing but with a JTree instead. The problem I have is the progress bars do not automatically refresh as they do the JTable example I found, instead they only refresh when they are clicked on, for the life of me I can't work out why? Also the second problem I have is that when I first expand my JTree, the expand icon disappears! Here's the code

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't read most of your code, but what has to happen is this: when a JProgressBar changes, it has to tell the model that it changed so that listeners to the model (i.e. the JTree) can react accordingly (i.e. redraw the node). If your tree model extends DefaultTreeModel, which apparently it does, that would require you to call "model.nodeChanged(treeNode)" where "treeNode" is the TreeNode object which contains that JProgressBar.
 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I didn't read most of your code, but what has to happen is this: when a JProgressBar changes, it has to tell the model that it changed so that listeners to the model (i.e. the JTree) can react accordingly (i.e. redraw the node). If your tree model extends DefaultTreeModel, which apparently it does, that would require you to call "model.nodeChanged(treeNode)" where "treeNode" is the TreeNode object which contains that JProgressBar.


Perfect thank you, I'm glad it was something simple!
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect thank you, I'm glad it was something simple!


- this notifier missing in JTree/DefaultTreeModel API

- you have to notify programatically by myTreeModel.nodeChanged()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic