List of usage examples for javax.swing JTree setName
public void setName(String name)
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * /*from w ww . java2 s . com*/ * @param name * @param model * @param cellRenderer * @return */ public static JTree tree(final String name, final TreeModel model, final TreeCellRenderer cellRenderer) { final JTree tree = new JTree(); tree.setName(name); tree.setModel(model); if (cellRenderer != null) { tree.setCellRenderer(cellRenderer); } return tree; }
From source file:it.imtech.metadata.MetaUtility.java
/** * Aggiunge il pannello delle classificazioni all'interfaccia dei metadati * * @param innerPanel Pannello sul quale aggiungere i metadati * @param kv Valori dei metadati/*from w w w .j a va 2 s. c o m*/ */ private void addClassification(JPanel innerPanel, Integer kv, final String sequence, final String panelname) throws Exception { try { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); DefaultMutableTreeNode hierarchy = new DefaultMutableTreeNode("root"); selected = null; String selectedPath = ""; String link = selectedClassificationList.get(panelname + "---" + sequence); recursiveOefosTreeviewBuild(hierarchy, oefos.get(link), sequence, panelname); DefaultTreeModel model = new DefaultTreeModel(hierarchy); final JTree tree = new JTree(model); tree.setRootVisible(false); if (selected != null) { TreePath selpath = new TreePath(selected.getPath()); tree.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); for (int i = 1; i < nodes.length; i++) { selectedPath += nodes[i].toString(); selectedPath += (i != nodes.length - 1) ? "/" : ""; } } tree.setName("MID_" + Integer.toString(kv) + "---" + sequence); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { try { setOEFOS(tree, sequence, panelname); } catch (Exception ex) { logger.error(ex.getMessage()); } } }); javax.swing.JScrollPane tree_scroller = new javax.swing.JScrollPane(); tree_scroller .setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); tree_scroller.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); tree_scroller.setViewportView(tree); tree_scroller.setBorder(null); innerPanel.add(tree_scroller, "wrap, width 100:800:800"); JPanel iPanel = new JPanel(new MigLayout()); iPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Utility.getBundleString("choose2", bundle), TitledBorder.LEFT, TitledBorder.TOP)); JLabel label = new JLabel(); label.setName("classification_path" + "---" + sequence); label.setText(selectedPath); iPanel.add(label, "wrap, growx, height 30:30:30"); innerPanel.add(iPanel, "wrap, width 100:800:800"); findLastClassification(panelname); } catch (Exception ex) { logger.error(ex.getMessage()); throw new Exception("Exception in addClassification: " + ex.getStackTrace() + "\n"); } }