Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeCellRenderer


   * This method initializes this
   *
   */
  private void initialize() {
        // Graphic settings
    renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(new ImageIcon(this.getClass().getClassLoader().getResource("images/match.png")));
      renderer.setClosedIcon(new ImageIcon(this.getClass().getClassLoader().getResource("images/folder_blue.png")));
      renderer.setOpenIcon(new ImageIcon(this.getClass().getClassLoader().getResource("images/folder_blue_open.png")));
   
        this.setLayout(new BorderLayout());
View Full Code Here


    private OutlineFieldJLabel[] cachedJLabels;

    public OutlineFieldCellRenderer(OutlineField pParent) {
        this.parent = pParent;
        this.hasRowHighlights = true;
        this.defaultTreeRenderer = new DefaultTreeCellRenderer();
        this.panel = new JPanel();
        this.panel.setLayout(new GridBagLayout());
        this.cachedJLabels = null;
    }
View Full Code Here

        else {
          tree.collapseRow(0);
        }
        tree.setOpaque(false);
        tree.setRowHeight(table.getRowHeight());
        tree.setCellRenderer(new DefaultTreeCellRenderer() {
          @Override
          public Color getBackground() {
            return null;
          }
          @Override
View Full Code Here

                    tcr = table.getDefaultRenderer(table.getColumnClass(column));
                }
                children.add(tcr.getTableCellRendererComponent(table, value, selected, focused, row, column));
            } else if (tree != null) {
                TreeCellRenderer tcr;
                tcr = new DefaultTreeCellRenderer();
                children.add(tcr.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focused));
            } else if (list != null) {
                ListCellRenderer lcr = (ListCellRenderer) UIManager.get("List.cellRenderer");
                if (lcr == null) {
                    lcr = new DefaultListCellRenderer();
View Full Code Here

     *  attributes and use those.
     */
    public Component getTreeCellRendererComponent(JTree tree, Object value,
            boolean selected, boolean expanded, boolean leaf, int row,
            boolean hasFocus) {
        DefaultTreeCellRenderer component = (DefaultTreeCellRenderer) super
                .getTreeCellRendererComponent(tree, value, selected, expanded,
                        leaf, row, hasFocus);

        if (value instanceof NamedObj) {
            NamedObj object = (NamedObj) value;

            // Fix the background colors because transparent
            // labels don't work quite right.
            if (!selected) {
                component.setBackground(tree.getBackground());
                component.setOpaque(true);
            } else {
                component.setOpaque(false);
            }

            if (object instanceof Settable) {
                StringBuffer buffer = new StringBuffer();
                buffer.append(object.getName());
                buffer.append("=");
                buffer.append(((Settable) object).getExpression());
                component.setText(buffer.toString().replace('\n', ' '));
            } else {
                component.setText(object.getName());
            }

            // Render an icon, if one has been defined.
            // NOTE: Avoid asking for attributes if the entity is a library
            // because this will trigger evaluation, defeating deferred
            // evaluation.
            if (!(object instanceof EntityLibrary)) {
                // Only if an object has an icon, an icon description, or
                // a small icon description is it rendered in the tree.
                List iconList = object.attributeList(EditorIcon.class);

                if ((iconList.size() > 0)
                        || (object.getAttribute("_iconDescription") != null)
                        || (object.getAttribute("_smallIconDescription") != null)) {
                    // NOTE: this code is similar to that in IconController.
                    EditorIcon icon = null;

                    try {
                        if (iconList.size() == 0) {
                            icon = new XMLIcon(object, "_icon");
                            icon.setPersistent(false);
                        } else {
                            icon = (EditorIcon) iconList
                                    .get(iconList.size() - 1);
                        }
                    } catch (KernelException ex) {
                        throw new InternalErrorException(
                                "could not create icon in "
                                        + object
                                        + " even though one did not previously exist.");
                    }

                    // Wow.. this is a confusing line of code.. :)
                    try {
                        component.setIcon(icon.createIcon());
                    } catch (Throwable throwable) {
                        // Ignore this, but print a message
                        System.err.println("Warning: Failed to create or "
                                + "set icon " + icon + " for component "
                                + component);
View Full Code Here

        if (node == null) return;
          String name = (String) node.getUserObject();
          showParamPanel(name);
        }
      });
      DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
      renderer.setLeafIcon(null);
      renderer.setOpenIcon(null);
      renderer.setClosedIcon(null);
      treeParam.setCellRenderer(renderer);

      treeParam.setRowHeight(18);
    }
    return treeParam;
View Full Code Here

    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {
      @Override
      public Component getTreeCellRendererComponent(JTree tree, Object value,
          boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row,
            hasFocus);
View Full Code Here

            super.updateUI();
            // Make the tree's cell renderer use the table's cell selection
            // colors.
            TreeCellRenderer tcr = getCellRenderer();
            if (tcr instanceof DefaultTreeCellRenderer) {
                DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
                // For 1.1 uncomment this, 1.2 has a bug that will cause an
                // exception to be thrown if the border selection color is
                // null.
                // dtcr.setBorderSelectionColor(null);
                dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
                dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
            }
        }
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

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.