Java Code Examples for javax.swing.JTree#setCellEditor()

The following examples show how to use javax.swing.JTree#setCellEditor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectDialog.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void initComponents()
{
	setLayout(new BorderLayout());

	mainPanel = new JPanel();
	mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

	JScrollPane mainScrollPane = new JScrollPane();
	mainScrollPane.setPreferredSize(new Dimension(300, 400));
	add(mainScrollPane, BorderLayout.CENTER);

	projectTree = new JTree();
	projectTree.setEditable(true);
	projectTree.setModel(new ProjectTreeModel(xmlProjectType));
	projectTree.setCellRenderer(new ProjectTreeCellRenderer(frame));
	projectTree.setCellEditor(new ProjectTreeCellEditor(projectTree));
	projectTree.getSelectionModel().setSelectionMode(
			TreeSelectionModel.SINGLE_TREE_SELECTION);
	projectTree.addMouseListener(new ProjectTreeMouseListener(frame,
			projectTree));
	projectTree.expandRow(1);

	mainScrollPane.getViewport().add(projectTree);

	pack();
}
 
Example 2
Source File: SLDTree.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Creates the ui. */
private void createUI() {
    setBorder(new LineBorder(new Color(0, 0, 0)));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel panelSymbolMarkerTree = new JPanel();
    add(panelSymbolMarkerTree);

    // CHECKSTYLE:OFF
    JScrollPane scrollpane = new JScrollPane();
    // CHECKSTYLE:ON

    rootNode = new DefaultMutableTreeNode("SLD");
    treeModel = new DefaultTreeModel(rootNode);
    symbolTree = new JTree(treeModel);
    symbolTree.setEditable(true);
    symbolTree.setBorder(new LineBorder(Color.black));
    ComponentCellRenderer cellRenderer =
            new ComponentCellRenderer(symbolTree.getCellRenderer());
    symbolTree.setCellRenderer(cellRenderer);
    symbolTree.setCellEditor(new CheckBoxNodeEditor(symbolTree, cellRenderer, this));
    symbolTree.setEditable(true);
    symbolTree.setRowHeight(0);

    // Listen for when the selection changes.
    symbolTree.addTreeSelectionListener(this);
    panelSymbolMarkerTree.setLayout(new BorderLayout(0, 0));

    scrollpane.setViewportView(symbolTree);

    panelSymbolMarkerTree.add(scrollpane);

    // Add the tree tools if they were supplied
    if (treeTools != null) {
        treeTools.configure(this, symbolTree, treeModel, renderList);
        add(treeTools.getButtonPanel());
    } else {
        setPreferredSize(new Dimension(SLDTreeTools.getPanelWidth(), PANEL_HEIGHT));
    }
}