Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeCellRenderer


        assertEquals(1, ui.depthOffset);
    }

    public void testUpdateCellEditor() {
        DefaultTreeCellEditor e1 = new DefaultTreeCellEditor(tree,
                new DefaultTreeCellRenderer());
        tree.setCellEditor(e1);
        assertSame(e1, tree.getCellEditor());
        assertNull(ui.cellEditor);
        assertSame(e1, ui.getCellEditor());
        tree.setEditable(true);
        assertSame(e1, ui.cellEditor);
        assertSame(e1, ui.getCellEditor());
        DefaultTreeCellEditor e2 = new DefaultTreeCellEditor(tree,
                new DefaultTreeCellRenderer());
        ui.cellEditor = e2;
        assertSame(e1, ui.getCellEditor());
        assertSame(e2, ui.cellEditor);
        ui.updateCellEditor();
        assertSame(e1, ui.cellEditor);
        assertSame(e1, tree.getCellEditor());
        ui.cellEditor = null;
        assertFalse(ui.createdCellEditor);
        ui.createdCellEditor = true;
        assertTrue(ui.createdCellEditor);
        ui.updateCellEditor();
        assertFalse(ui.createdCellEditor);
        assertSame(e1, ui.cellEditor);
        assertSame(e1, tree.getCellEditor());
        tree.setCellRenderer(new DefaultTreeCellRenderer());
        assertFalse(ui.createdCellEditor);
        assertSame(e1, ui.cellEditor);
        assertSame(e1, tree.getCellEditor());
        ui.createdCellEditor = true;
        tree.setCellRenderer(new DefaultTreeCellRenderer());
        assertTrue(ui.createdCellEditor);
        assertNotSame(e1, ui.cellEditor);
        assertNotSame(e1, tree.getCellEditor());
    }
View Full Code Here


        assertNotSame(e1, ui.cellEditor);
        assertNotSame(e1, tree.getCellEditor());
    }

    public void testUpdateRenderer() {
        DefaultTreeCellRenderer r1 = new DefaultTreeCellRenderer();
        tree.setCellRenderer(r1);
        assertSame(r1, tree.getCellRenderer());
        assertSame(r1, ui.currentCellRenderer);
        assertSame(r1, ui.getCellRenderer());
        DefaultTreeCellRenderer r2 = new DefaultTreeCellRenderer();
        ui.currentCellRenderer = r2;
        assertSame(r2, ui.getCellRenderer());
        ui.updateRenderer();
        assertSame(r1, ui.currentCellRenderer);
        assertSame(r1, tree.getCellRenderer());
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

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        tree = new JTree();
        tree.setCellRenderer(new DefaultTreeCellRenderer() {
            @Override
            public FontMetrics getFontMetrics(Font f) {
                return JTreeTest.this.getFontMetrics(f, 10, 10);
            }
        });
View Full Code Here

        assertSame(tree.accessibleContext, tree.getAccessibleContext());
    }

    public void testGetToolTipTextMouseEvent() {
        tree.setToolTipText("tip");
        tree.cellRenderer = new DefaultTreeCellRenderer() {
            @Override
            public String getToolTipText() {
                return "renderer tip";
            }
        };
View Full Code Here

        assertNull(tree.getCellEditor());
    }

    public void testSetCellRenderer() {
        PropertyChangeController listener = new PropertyChangeController();
        TreeCellRenderer renderer1 = new DefaultTreeCellRenderer();
        TreeCellRenderer renderer2 = new DefaultTreeCellRenderer();
        tree.addPropertyChangeListener(listener);
        TreeCellRenderer oldRenderer = tree.getCellRenderer();
        tree.setCellRenderer(renderer1);
        listener.checkPropertyFired(tree, "cellRenderer", oldRenderer, renderer1);
        assertEquals("cellRenderer", renderer1, tree.getCellRenderer());
View Full Code Here

        tree.setPreferredSize(new Dimension(100, 200));
        tree.setVisibleRowCount(0);
        assertEquals(new Dimension(100, 0), tree.getPreferredScrollableViewportSize());
        tree.setVisibleRowCount(1);
        assertEquals(new Dimension(100, 18), tree.getPreferredScrollableViewportSize());
        tree.setCellRenderer(new DefaultTreeCellRenderer() {
            @Override
            public Component getTreeCellRendererComponent(final JTree tree, final Object value,
                    final boolean selected, final boolean expanded, final boolean leaf,
                    final int row, final boolean hasFocus) {
                JComponent result = (JComponent) super.getTreeCellRendererComponent(tree,
View Full Code Here

        this.treeModel = new ComponentTreeModel(new ComponentTreeNode("Components"));
        this.tree = new JTree(this.treeModel);

        // Add a tool tip.
        ToolTipManager.sharedInstance().registerComponent(this.tree);
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
            @Override
            public java.awt.Component getTreeCellRendererComponent(JTree t, Object value, boolean sel,
                    boolean expanded, boolean leaf, int row, boolean focus) {
                super.getTreeCellRendererComponent(t, value, sel, expanded, leaf, row, focus);

                ComponentTreeNode node = (ComponentTreeNode) value;
                if (node.getComponentReference() == null) {
                    setToolTipText(null);
                } else {
                    setToolTipText("Drag a component to the composer to add");
                }
                return this;
            }
        };

        // Change icons
        try {
            renderer.setOpenIcon(SwingUtil.createImageIcon("opened.gif"));
            renderer.setClosedIcon(SwingUtil.createImageIcon("closed.gif"));
            renderer.setLeafIcon(SwingUtil.createImageIcon("leaf.gif"));
        } catch (RuntimeException e) {
            logger.warn("Failed to load image icons.  " + "It will use the default icons instead.", e);
        }

        this.tree.setCellRenderer(renderer);
View Full Code Here

     * Create the tree cell renderer used to draw the nodes in the test tree.
     *
     * @return a renderer to draw the test tree nodes
     */
    protected TreeCellRenderer getCellRenderer() {
        DefaultTreeCellRenderer rend = new ReportCellRenderer();
        rend.setFont(new Font("Dialog", Font.PLAIN, 11));
        return rend;
    }
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

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.