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

The following examples show how to use javax.swing.JTree#setEditable() . 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: JSONTree.java    From rest-client with Apache License 2.0 6 votes vote down vote up
/**
* 
* @Title      : JSONTree 
* @Description: Default constructor 
* @Param      :
 */
public JSONTree()
{
    super(new GridLayout(1, 0));

    rootNode = new CheckBoxTreeNode(RESTConst.JSON);
    treeModel = new DefaultTreeModel(rootNode);

    tree = new JTree(treeModel);
    tree.setCellRenderer(new CheckBoxTreeCellRenderer());
    tree.setEditable(false);
    tree.setToolTipText(RESTConst.EXCLUDE_NODE);
    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addMouseListener(ma);

    JScrollPane scrollPane = new JScrollPane(tree);
    this.add(scrollPane);
    this.initPopupMenu();
}
 
Example 2
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 3
Source File: ProductLayerAssistantPage.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Component createPageComponent() {
    ProductTreeModel model = createTreeModel();
    tree = new JTree(model);
    tree.setEditable(false);
    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    tree.setCellRenderer(new ProductNodeTreeCellRenderer());
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.getSelectionModel().addTreeSelectionListener(new ProductNodeSelectionListener());

    List<CompatibleNodeList> nodeLists = model.compatibleNodeLists;
    for (CompatibleNodeList nodeList : nodeLists) {
        tree.expandPath(new TreePath(new Object[]{nodeLists, nodeList}));
    }

    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.setBorder(new EmptyBorder(4, 4, 4, 4));
    panel.add(new JLabel("Compatible bands and tie-point grids:"), BorderLayout.NORTH);
    panel.add(new JScrollPane(tree), BorderLayout.CENTER);
    return panel;
}
 
Example 4
Source File: DynamicTree.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public DynamicTree() {
    super(new GridLayout(1, 0));

    rootNode = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(rootNode);
    treeModel.addTreeModelListener(new MyTreeModelListener());
    tree = new JTree(treeModel);
    tree.setEditable(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);

    JScrollPane scrollPane = new JScrollPane(tree);
    add(scrollPane);
}
 
Example 5
Source File: ModelsPanel.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
    treeModel.setRoot(createRoot());

    tree = new JTree(treeModel) {
        @Override
        public TreeCellRenderer getCellRenderer() {
            TreeCellRenderer renderer = super.getCellRenderer();
            if (renderer == null)
                return null;
            ((DefaultTreeCellRenderer) renderer).setLeafIcon(new ImageIcon(
                    getClass().getResource("/images/function.png")));
            return renderer;
        }
    };

    tree.setCellRenderer(new Renderer());

    tree.setEditable(true);

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1)
                    && (e.getClickCount() == 2)) {
                openDiagram();
            }
        }

    });

    tree.setRootVisible(true);

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane, BorderLayout.CENTER);
}
 
Example 6
Source File: GUIBrowser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addWindowTab() {
    if (compNode instanceof WindowNode
            && ((WindowNode) compNode).getWindows().length > 0) {
        winTree = new JTree(((WindowNode) compNode).getWindowModel());
        winTree.setCellRenderer(renderer);
        winTree.setEditable(false);
        winTree.addTreeSelectionListener(selManager);
        winSplit = createUnderPane(winTree);
        tbd.add(WINDOWS_TAB, winSplit);
    }

}
 
Example 7
Source File: GUIBrowser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addComponentTab() {
    if (compNode instanceof ContainerNode
            && ((ContainerNode) compNode).getComponents().length > 0) {
        componentTree = new JTree(((ContainerNode) compNode).getComponentModel());
        componentTree.setCellRenderer(renderer);
        componentTree.setEditable(false);
        componentTree.addTreeSelectionListener(selManager);
        componentSplit = createUnderPane(componentTree);
        tbd.add(COMPONENTS_TAB, componentSplit);
    }

}
 
Example 8
Source File: GUIBrowser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addReflectionTab() {
    methodTree = new JTree(compNode.getMethodsModel());
    methodTree.setCellRenderer(renderer);
    methodTree.setEditable(false);
    methodTree.addTreeSelectionListener(selManager);
    tbd.add(REFLECTION_TAB, new JScrollPane(methodTree));
}
 
Example 9
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));
    }
}
 
Example 10
Source File: DataViewBuilders.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void setupInstance(JTree instance) {
    super.setupInstance(instance);
    
    instance.setEditable(editable);
}
 
Example 11
Source File: DataViewBuilders.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
protected void setupInstance(JTree instance) {
    super.setupInstance(instance);
    
    instance.setEditable(editable);
}