treecellrenderer

How do you make components of JPanel as a node in JTree usable?

别等时光非礼了梦想. 提交于 2019-11-28 09:59:08
问题 When I click on the JButton nothing happens. This applies even for a JScrollPane that I put in (it shows, but will not scroll). Why is the JPanel not at the front? I get the sense that something has to be overridden. Should it be the expansion of the part that is not the arrow? If so, how is that done? import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.tree.*; public class test { public test() { JTree tree =

Set icon to each node in Jtree

久未见 提交于 2019-11-28 00:07:05
问题 I want to set for each node in my JTree a different icon, actually I'm loading each node from a data base, with a "while", I set each icon like a root, leaf or parent. Like this: All my declarations are global: private ResultSet myResultSet; protected DefaultTreeModel treeModel; private DefaultMutableTreeNode rootNode,childNode,parent1,parent2; And this is the code where I set my nodes: myResultSet=rtnNodes(); /*Method that returns a RS with my nodes*/ while(myResultSet.next()){ switch

JTree: Set custom open/closed icons for individual groups

為{幸葍}努か 提交于 2019-11-27 09:22:29
I know how to set custom leaf icons in JTree I know how to set custom closed/open icons for all group nodes But I can not set custom open/closed icons based on the group node names, for example of node could be called Emails (so it is nice to have an envelop icon) or one group may be called tasks and so on. I tried to do this by overriding the getTreeCellRendererComponent method of class DefaultTreeCellRenderer But changing the icon for the current node will affect for the next node only! How to set custom open/closed icons for individual groups? Please take a look at my code: Employee.java

JTree: Set custom open/closed icons for individual groups

梦想的初衷 提交于 2019-11-26 14:39:49
问题 I know how to set custom leaf icons in JTree I know how to set custom closed/open icons for all group nodes But I can not set custom open/closed icons based on the group node names, for example of node could be called Emails (so it is nice to have an envelop icon) or one group may be called tasks and so on. I tried to do this by overriding the getTreeCellRendererComponent method of class DefaultTreeCellRenderer But changing the icon for the current node will affect for the next node only! How