Package javax.swing.tree

Examples of javax.swing.tree.TreeCellRenderer


  /**
   * Returns the label text of <code>node</code> in <code>tree</code>.
   */
  private String getNodeText(JTree tree, Object node) {
    TreeCellRenderer renderer = tree.getCellRenderer();
    Component childLabel = renderer.
        getTreeCellRendererComponent(tree, node,
           false, true, false, 0, false);
    return ((JLabel)childLabel).getText();
  }
View Full Code Here


    _treeRendererDelegate = new DefaultTreeRenderer();

    _categoryTree = new JXTree(rootNode);
    _categoryTree.setOpaque(false);
    _categoryTree.setCellRenderer(new TreeCellRenderer() {

      @Override
      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
          boolean leaf, int row, boolean hasFocus) {
        Icon icon = null;
View Full Code Here

    }

    final DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);

    final JXTree tree = new JXTree();
    tree.setCellRenderer(new TreeCellRenderer() {
      @Override
      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
          boolean leaf, int row, boolean hasFocus) {
        if (value instanceof DefaultMutableTreeNode) {
          final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
View Full Code Here

      // Must be registered for renderer tooltips to work
      ToolTipManager.sharedInstance().registerComponent(recordTree);

      // Load leaf icon for the tree cell renderer.
      TreeCellRenderer renderer = new DefaultTreeCellRenderer() {
          public Component getTreeCellRendererComponent(JTree tree,
                                                        Object value,
                                                        boolean sel,
                                                        boolean expanded,
                                                        boolean leaf,
View Full Code Here

    }

    public Component getRendererComponent() {
        TreeModel treeModel = tree.getModel();
        TreePath treePath = tree.getPathForRow(rowIndex);
        TreeCellRenderer renderer = tree.getCellRenderer();
        boolean isSelected = tree.isPathSelected(treePath);
        boolean isExpanded = tree.isExpanded(treePath);
        boolean hasFocus = tree.hasFocus() && rowIndex == tree.getLeadSelectionRow();
        Object item = treePath.getLastPathComponent();
        boolean isLeaf = treeModel.isLeaf(item);
        Component component = renderer.getTreeCellRendererComponent(tree, item, isSelected, isExpanded, isLeaf, rowIndex, hasFocus);
        component.setFont(tree.getFont());
        return component;
    }
View Full Code Here

        setBackground(LightZoneSkin.Colors.ToolPanesBackground);

        setFocusable(false);

        TreeCellRenderer renderer = FolderTreeCellRenderer.createRenderer();
        setCellRenderer(renderer);

        FolderTreeTransferHandler trans = new FolderTreeTransferHandler(this);
        setTransferHandler(trans);
View Full Code Here

   * @return the internal value of a cell in a {@code JTree} as expected in a test.
   */
  @Override
  @RunsInCurrentThread
  public @Nullable String valueAt(@Nonnull JTree tree, @Nullable Object modelValue) {
    TreeCellRenderer r = tree.getCellRenderer();
    Component c = r.getTreeCellRendererComponent(tree, modelValue, false, false, false, 0, false);
    String value = (c != null) ? rendererReader.valueFrom(c) : null;
    if (value != null) {
      return value;
    }
    value = tree.convertValueToText(modelValue, false, false, false, 0, false);
View Full Code Here

     */
    public void updateUI() {
      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.
View Full Code Here

      }
     
      visibleRow = row;
      setBackground(background);

      TreeCellRenderer tcr = getCellRenderer();
      if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
        if (isSelected) {
          dtcr.setTextSelectionColor(foreground);
          dtcr.setBackgroundSelectionColor(background);
View Full Code Here

      JTree t = getTree();
      boolean rv = t.isRootVisible();
      int offsetRow = rv ? r : r - 1;
      Rectangle bounds = t.getRowBounds(offsetRow);
      int offset = bounds.x;
      TreeCellRenderer tcr = t.getCellRenderer();
      if (tcr instanceof DefaultTreeCellRenderer) {
        Object node = t.getPathForRow(offsetRow).getLastPathComponent();
        Icon icon;
        if (t.getModel().isLeaf(node))
          icon = ((DefaultTreeCellRenderer) tcr).getLeafIcon();
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeCellRenderer

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.