Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeCellRenderer


    _tree = new JTree(new DefaultTreeModel(root));
    _tree.setShowsRootHandles(true);
    _tree.addTreeSelectionListener(new ObjectTreeSelectionListener());

    // Renderer for tree.
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    SquirrelResources rsrc = _app.getResources();
    renderer.setLeafIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOPIC));
    renderer.setOpenIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_OPEN));
    renderer.setClosedIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_CLOSED));
    _tree.setCellRenderer(renderer);

     // First put the Welcome to SQuirreL node.
     File file = appFiles.getWelcomeFile();
     try
View Full Code Here


      Rectangle boundsBuffer = new Rectangle();
            Rectangle rowBounds = new Rectangle(0, 0, tree.getWidth(),0);
      Rectangle bounds;
      TreePath path;
            TreeCellRenderer renderer = tree.getCellRenderer();
            DefaultTreeCellRenderer dtcr = (renderer instanceof
                       DefaultTreeCellRenderer) ? (DefaultTreeCellRenderer)
                       renderer : null;

            configureRenderer(cellContext);
      while (!done && paintingEnumerator.hasMoreElements()) {
View Full Code Here

    private void configureRenderer(SynthContext context) {
        TreeCellRenderer renderer = tree.getCellRenderer();

        if (renderer instanceof DefaultTreeCellRenderer) {
            DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
            SynthStyle style = context.getStyle();

            context.setComponentState(ENABLED | SELECTED);
            Color color = r.getTextSelectionColor();
            if (color == null || (color instanceof UIResource)) {
                r.setTextSelectionColor(style.getColor(
                                     context, ColorType.TEXT_FOREGROUND));
            }
            color = r.getBackgroundSelectionColor();
            if (color == null || (color instanceof UIResource)) {
                r.setBackgroundSelectionColor(style.getColor(
                                        context, ColorType.TEXT_BACKGROUND));
            }

            context.setComponentState(ENABLED);
            color = r.getTextNonSelectionColor();
            if (color == null || color instanceof UIResource) {
                r.setTextNonSelectionColor(style.getColorForState(
                                        context, ColorType.TEXT_FOREGROUND));
            }
            color = r.getBackgroundNonSelectionColor();
            if (color == null || color instanceof UIResource) {
                r.setBackgroundNonSelectionColor(style.getColorForState(
                                  context, ColorType.TEXT_BACKGROUND));
            }
        }
    }
View Full Code Here

    tree.setShowsRootHandles(true); // Displays node expansion glyphs.

    TreeSelectionModel selectionModel = tree.getSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
    tree.setCellRenderer(cellRenderer);

    scrollPane.getViewport().add(tree, null);
  }
View Full Code Here

    tree.setShowsRootHandles(true); // Displays node expansion glyphs.

    TreeSelectionModel selectionModel = tree.getSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
    tree.setCellRenderer(cellRenderer);

    scrollPane.getViewport().add(tree, null);
  }
View Full Code Here

    this.indexTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
    // Only one node can be selected at any one time.
    this.indexTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.indexTree.addTreeSelectionListener(new IndexTreeSelectionListener(this));
    // No icons.
    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    // cellRenderer.setIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
    this.indexTree.setCellRenderer(cellRenderer);
  }
View Full Code Here

    this.fsTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
    this.fsTree.setLargeModel(true);
    // Only one node can be selected at any one time.
    this.fsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.fsTree.addTreeSelectionListener(new FSTreeSelectionListener(this));
    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    // cellRenderer.setIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
    this.fsTree.setCellRenderer(cellRenderer);
  }
View Full Code Here

    TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
    treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.typeTree.setSelectionModel(treeSelectionModel);
    JScrollPane treePane = new JScrollPane(this.typeTree);
    contentPane.setLeftComponent(treePane);
    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    // cellRenderer.setIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
    this.typeTree.setCellRenderer(cellRenderer);

    // Set up the feature table.
    this.featureTable = new JTable(new FeatureTableModel());
    JScrollPane featurePane = new JScrollPane(this.featureTable);
View Full Code Here

        assertEquals(-20, ui.getRowHeight());
    }

    public void testSetGetCellRenderer() {
        assertTrue(ui.getCellRenderer() instanceof DefaultTreeCellRenderer);
        DefaultTreeCellRenderer r = new DefaultTreeCellRenderer();
        tree.setCellRenderer(r);
        assertEquals(r, ui.getCellRenderer());
        assertEquals(r, ui.currentCellRenderer);
        ui.setCellRenderer(new DefaultTreeCellRenderer());
        assertEquals(r, ui.currentCellRenderer);
        assertEquals(r, ui.getCellRenderer());
        ui.createdRenderer = false;
        assertFalse(ui.createdRenderer);
        ui.currentCellRenderer = null;
        ui.setCellRenderer(null);
        assertFalse(ui.createdRenderer);
        assertEquals(r, ui.currentCellRenderer);
        assertEquals(r, ui.getCellRenderer());
        tree.setCellRenderer(new DefaultTreeCellRenderer());
        assertNotNull(tree.getCellRenderer());
        assertNotNull(ui.getCellRenderer());
    }
View Full Code Here

    }

    public void testSetGetCellEditor() {
        assertNull(ui.getCellEditor());
        DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree,
                new DefaultTreeCellRenderer());
        tree.setCellEditor(editor);
        assertEquals(editor, ui.getCellEditor());
        ui.setCellEditor(new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()));
        assertEquals(editor, ui.getCellEditor());
    }
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultTreeCellRenderer

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.