I am trying to remove the folder symbol from node of JTree which comes by default. How can I accomplish this?
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
renderer.setLeafIcon(null);
renderer.setClosedIcon(null);
renderer.setOpenIcon(null);
The jtree uses CellRender, for example DefaultTreeCellRenderer, and you can dasable or change default nodes icon. Also, you can create custom cellRender and defined more dificult logic for you icon scheme.
tree.setCellRenderer(new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
ImageIcon iconPath = ((WizardNode) value).getIcon();
component.setIcon(iconPath);
return this;
}
});