Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #339
| From | "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Dynamically Update JT |
| Message-ID | <1165444204.503636.301140@79g2000cws.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1165430688.739800.181760@80g2000cwy.googlegroups.com> |
| Date | 2011-04-27 15:26 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui On Dec 6, 1:44 pm, "Jason Cavett" <jason.cav...@gmail.com> wrote: > I'm trying to program the ability for a node on my JTree to have its > icon change when the node is opened. However, althought it *seems* > that the icon is benig changed (see the code below), the JTree does not > refresh (or at least it doesn't appear that way). Any tips/hints/ideas > on where to go with this? > > ((MyOwnCellRenderer) > this.getCellRenderer()).setEditIcon(model.getSelected()); > System.out.println(((HasrdTreeCellRenderer) > this.getCellRenderer()).getIcon()); > // the icon has been updated based on the println > revalidate(); > repaint(); I think the problem has to do with how I use my cell renderer. When I create my tree, I do something like this... JTree tree = new JTree(); tree.setCellRenderer(new MyOwnTreeCellRenderer()); Within my tree cell renderer (which extends DefaultTreeCellRenderer) I override the method getTreeCellRendererComponent. This is where I have the logic to set icons based on what item is in the tree. The problem I'm having is that if I update one icon, it updates every other node in the tree. I'm not understanding how to update one single node in the tree using the TreeCellRenderer (if this is even possible). Any suggestions? --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar
Re: Dynamically Update JT "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
Re: Dynamically Update JT "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
Re: Dynamically Update JT "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
Re: Dynamically Update JT "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
Re: Dynamically Update JT "Jim Sculley" <jim.sculley@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
csiph-web