Hi! I´ve done a tree but it doesn´t display...even it doesn´t allow other components to appear... here is part of the code.
private JScrollPane treeView;
private JTree treeInicio;
protected DefaultTreeModel treeModel;
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Root");
private Toolkit toolkit = Toolkit.getDefaultToolkit();
DefaultTreeCellRenderer iconoDiagrama;
public void tree(){
iconoDiagrama= (DefaultTreeCellRenderer)treeInicio.getCellRenderer();
iconoDiagrama.setLeafIcon(new ImageIcon("Icono.gif"));
DefaultMutableTreeNode plant1 = new DefaultMutableTreeNode("plantilla 1");
DefaultMutableTreeNode plant2 = new DefaultMutableTreeNode("plantilla 2");
DefaultMutableTreeNode diag11 = new DefaultMutableTreeNode("diagrama 11");
DefaultMutableTreeNode diag12 = new DefaultMutableTreeNode("diagrama 12");
DefaultMutableTreeNode diag13 = new DefaultMutableTreeNode("diagrama 13");
DefaultMutableTreeNode diag21 = new DefaultMutableTreeNode("diagrama 21");
DefaultMutableTreeNode diag22 = new DefaultMutableTreeNode("diagrama 22");
top.add(plant1);
plant1.add(diag11);
plant1.add(diag12);
plant1.add(diag13);
top.add(plant2);
plant2.add(diag21);
plant2.add(diag22);
treeModel = new DefaultTreeModel(top);
treeInicio = new JTree(treeModel);
treeInicio.setEditable(true);
treeInicio.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
//treeView = new JScrollPane(treeInicio);
}
I don´t know if I have to add to my panel treeInicio or treeView... Here´s the rest of the code
plantillas.add(treeInicio, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
thanks for your time