Package javax.swing.tree

Examples of javax.swing.tree.TreeCellEditor


                valueMarker.setOccurred(messageTree);
            }
        };
        ui.installUI(tree);
        final Marker editorMarker = new Marker();
        TreeCellEditor editor = new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()) {
            @Override
            public boolean stopCellEditing() {
                editorMarker.setOccurred();
                return super.stopCellEditing();
            }
View Full Code Here


        DefaultTreeCellEditor editor1 = new DefaultTreeCellEditor(tree,
                (DefaultTreeCellRenderer) tree.getCellRenderer());
        DefaultTreeCellEditor editor2 = new DefaultTreeCellEditor(tree,
                (DefaultTreeCellRenderer) tree.getCellRenderer());
        tree.addPropertyChangeListener(listener);
        TreeCellEditor oldEditor = tree.getCellEditor();
        tree.setCellEditor(editor1);
        listener.checkPropertyFired(tree, "cellEditor", oldEditor, editor1);
        assertEquals("cellEditor", editor1, tree.getCellEditor());
        tree.setEditable(true);
        listener.reset();
View Full Code Here

        return finder.getMComponentByComponent(rendererComponent, "doesn't matter", null);
    }

    public MComponent getEditor() {
        JTree tree = getTreeComponent();
        TreeCellEditor cellEditor = (TreeCellEditor) eventQueueRunner.invoke(tree, "getCellEditor");
        if (cellEditor == null)
            return null;
        boolean isSelected = eventQueueRunner.invokeBoolean(tree, "isRowSelected", new Object[] { Integer.valueOf(row) },
                new Class[] { Integer.TYPE });
        boolean isExpanded = eventQueueRunner.invokeBoolean(tree, "isExpanded", new Object[] { Integer.valueOf(row) },
                new Class[] { Integer.TYPE });
        TreePath treePath = (TreePath) eventQueueRunner.invoke(tree, "getPathForRow", new Object[] { Integer.valueOf(row) },
                new Class[] { Integer.TYPE });
        if (treePath == null)
            return null;
        boolean isLeaf = false;
        Component editor = cellEditor.getTreeCellEditorComponent(tree, treePath.getLastPathComponent(), isSelected, isExpanded,
                isLeaf, row);
        if (editor == null)
            return null;
        if (editor instanceof Container) {
            editor = ((Container) editor).getComponent(0);
View Full Code Here

    public boolean isEditable() {
        return editable;
    }

    public void setCellEditor(TreeCellEditor editor) {
        TreeCellEditor oldValue = cellEditor;
        cellEditor = editor;
        firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
    }
View Full Code Here

        DefaultTreeCellEditor editor1 = new DefaultTreeCellEditor(tree,
                (DefaultTreeCellRenderer) tree.getCellRenderer());
        DefaultTreeCellEditor editor2 = new DefaultTreeCellEditor(tree,
                (DefaultTreeCellRenderer) tree.getCellRenderer());
        tree.addPropertyChangeListener(listener);
        TreeCellEditor oldEditor = tree.getCellEditor();
        tree.setCellEditor(editor1);
        listener.checkPropertyFired(tree, "cellEditor", oldEditor, editor1);
        assertEquals("cellEditor", editor1, tree.getCellEditor());
        tree.setEditable(true);
        listener.reset();
View Full Code Here

                valueMarker.setOccurred(messageTree);
            }
        };
        ui.installUI(tree);
        final Marker editorMarker = new Marker();
        TreeCellEditor editor = new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()) {
            @Override
            public boolean stopCellEditing() {
                editorMarker.setOccurred();
                return super.stopCellEditing();
            }
View Full Code Here

    tree.removeKeyListener(keyListener);
    tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
    tree.removeComponentListener(componentListener);
    tree.removeTreeExpansionListener(treeExpansionListener);

    TreeCellEditor tce = tree.getCellEditor();
    if (tce != null)
      tce.removeCellEditorListener(cellEditorListener);
    if (treeModel != null)
      treeModel.removeTreeModelListener(treeModelListener);
  }
View Full Code Here

   * basic one will be used.
   */
  protected void updateCellEditor()
  {
    completeEditing();
    TreeCellEditor newEd = null;
    if (tree != null && tree.isEditable())
      {
        newEd = tree.getCellEditor();
        if (newEd == null)
          {
View Full Code Here

    if (isEditing(tree) && tree.getInvokesStopCellEditing()
        && ! stopEditing(tree))
      return false;

    completeEditing();
    TreeCellEditor ed = cellEditor;
    if (ed != null && tree.isPathEditable(path))
      {
        if (ed.isCellEditable(event))
          {
            editingRow = getRowForPath(tree, path);
            Object value = path.getLastPathComponent();
            boolean isSelected = tree.isPathSelected(path);
            boolean isExpanded = tree.isExpanded(editingPath);
            boolean isLeaf = treeModel.isLeaf(value);
            editingComponent = ed.getTreeCellEditorComponent(tree, value,
                                                             isSelected,
                                                             isExpanded,
                                                             isLeaf,
                                                             editingRow);

            Rectangle bounds = getPathBounds(tree, path);

            Dimension size = editingComponent.getPreferredSize();
            int rowHeight = getRowHeight();
            if (size.height != bounds.height && rowHeight > 0)
              size.height = rowHeight;

            if (size.width != bounds.width || size.height != bounds.height)
              {
                editorHasDifferentSize = true;
                treeState.invalidatePathBounds(path);
                updateSize();
              }
            else
              editorHasDifferentSize = false;

            // The editing component must be added to its container. We add the
            // container, not the editing component itself.
            tree.add(editingComponent);
            editingComponent.setBounds(bounds.x, bounds.y, size.width,
                                       size.height);
            editingComponent.validate();
            editingPath = path;

            if (ed.shouldSelectCell(event))
              {
                stopEditingInCompleteEditing = false;
                tree.setSelectionRow(editingRow);
                stopEditingInCompleteEditing = true;
              }
View Full Code Here

            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
        } else {
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        }
       
        TreeCellEditor tce = new DirectoryCellEditor(tree, fileChooser, new JTextField());
        tree.setCellEditor(tce);
        tce.addCellEditorListener(dirHandler);
        tree.setCellRenderer(new DirectoryTreeRenderer());
        JScrollPane scrollBar = new JScrollPane(tree);
        scrollBar.setViewportView(tree);
        tree.setInvokesStopCellEditing(true);
       
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeCellEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.