コード例 #1
0
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      if (!(value instanceof File)) {
        labelRenderer.getTreeCellRendererComponent(tree, value, sel, expanded, false, row, false);
        labelRenderer.setIcon(null);
        return labelRenderer;
      }

      File file = (File) value;
      checkBox.setText(RecursiveLibraryDirectoryPanel.this.getText(file));
      // setColors(compTemp, tree, tree.getPathForRow(row), checkBox, sel);
      checkBox.setBackground(this.getBackground());
      checkBox.setForeground(this.getForeground());

      if (isExcluded(file)) {
        checkBox.setSelected(false);
        checkBox.setIcon(null);
      } else if (isFullyIncluded(file)) {
        checkBox.setSelected(true);
        checkBox.setIcon(null);
      } else {
        checkBox.setSelected(true);
        checkBox.setIcon(partiallyIncludedIcon);
      }
      return checkBox;
    }
コード例 #2
0
  /**
   * This method initializes treeParam
   *
   * @return javax.swing.JTree
   */
  private JTree getTreeParam() {
    if (treeParam == null) {
      treeParam = new JTree();
      treeParam.setModel(getTreeModel());
      treeParam.setShowsRootHandles(true);
      treeParam.setRootVisible(true);
      treeParam.addTreeSelectionListener(
          new javax.swing.event.TreeSelectionListener() {

            public void valueChanged(javax.swing.event.TreeSelectionEvent e) {

              DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) getTreeParam().getLastSelectedPathComponent();
              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;
  }
コード例 #3
0
 public void updateUI() {
   super.updateUI();
   TreeCellRenderer tcr = super.getCellRenderer();
   if (tcr instanceof DefaultTreeCellRenderer) {
     DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tcr;
     dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground());
     dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground());
   }
 }
コード例 #4
0
ファイル: TreeIconDemo.java プロジェクト: wxylon/xylon-role
  public TreeIconDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
      DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
      renderer.setLeafIcon(leafIcon);
      tree.setCellRenderer(renderer);
    } else {
      System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
    // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
  }
 public Component getTreeCellRendererComponent(
     JTree tree,
     Object value,
     boolean sel,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
   TreeNodeObject nodeObject = (TreeNodeObject) node.getUserObject();
   if (nodeObject.isLogger()) {
     Level level = nodeObject.getLogger().getLevel();
     if (level == null) {
       super.setClosedIcon(loggerNoLevel);
       super.setOpenIcon(loggerNoLevel);
       super.setLeafIcon(loggerNoLevel);
     } else {
       super.setClosedIcon(loggerWithLevel);
       super.setOpenIcon(loggerWithLevel);
       super.setLeafIcon(loggerWithLevel);
     }
   } else {
     super.setClosedIcon(noLoggerIcon);
     super.setOpenIcon(noLoggerIcon);
   }
   return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
 }
コード例 #6
0
  private void init(DefaultTreeModel model) {
    tree = getTree(model);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) getTree().getCellRenderer();
    Icon openIcon = new ImageIcon("src/com/geopista/app/alfresco/ui/image/folder_open.png");
    // Icon leafIcon = new ImageIcon("src/com/geopista/app/alfresco/ui/image/folder_close.png");
    Icon closedIcon = new ImageIcon("src/com/geopista/app/alfresco/ui/image/folder_close.png");
    renderer.setOpenIcon(openIcon);
    // renderer.setLeafIcon(leafIcon);
    renderer.setLeafIcon(openIcon);
    renderer.setClosedIcon(closedIcon);

    setLayout(new BorderLayout());
    add(getTree(), BorderLayout.CENTER);
  }
コード例 #7
0
  @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);

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    Object nodeInfo = node.getUserObject();

    if (nodeInfo instanceof Severity) {
      Severity s = (Severity) nodeInfo;
      setIcon(ImageProvider.get("data", s.getIcon()));
    } else if (nodeInfo instanceof TestError) {
      TestError error = (TestError) nodeInfo;
      MultipleNameVisitor v = new MultipleNameVisitor();
      v.visit(error.getPrimitives());
      setText(v.getText());
      setIcon(v.getIcon());
    }
    return this;
  }
コード例 #8
0
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean sel,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {

    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    Object userObject = node.getUserObject();

    if (userObject instanceof UserObject) {
      ImageIcon icon = ((UserObject) userObject).getIcon();

      if (icon != null) {
        setIcon(icon);
      }
    }

    return this;
  }
コード例 #9
0
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean sel,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {

    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

    // System.out.println("La fila es: "+row+" value:"+ value);
    if (row == 0) {
      setIcon(rootIcon);
    }
    // else if (row==1)
    // {    setIcon(bienesIcon);}
    else {
      setIcon(subBienesIcon);
    }
    String sTitle = getNameNode(value);
    if (sTitle != null) {
      this.setName(sTitle);
      this.setText(sTitle);
    }

    return this;
  }
コード例 #10
0
ファイル: EntityPallet.java プロジェクト: mchudleigh/jaamsim
    @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);

      // If not a leaf, just return
      if (!leaf) return this;

      // If we don't find an ObjectType (likely we will) just return
      Object userObj = ((DefaultMutableTreeNode) value).getUserObject();
      if (!(userObj instanceof ObjectType)) return this;

      ObjectType type = (ObjectType) userObj;
      this.setText(type.getName());

      if (!RenderManager.isGood()) return this;

      if (type.getIconImage() == null) return this;

      icon.setImage(type.getIconImage());
      this.setIcon(icon);
      return this;
    }
コード例 #11
0
 /**
  * updateUI is overridden to set the colors of the Tree's renderer to match that of the table.
  */
 @Override
 public void updateUI() {
   super.updateUI();
   // Make the tree's cell renderer use the table's cell selection
   // colors.
   final TreeCellRenderer tcr = getCellRenderer();
   if (tcr instanceof DefaultTreeCellRenderer) {
     final 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"));
   }
 }
コード例 #12
0
 @Override
 public Component getTreeCellRendererComponent(
     JTree tree,
     Object value,
     boolean sel,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   //   System.out.println(value);
   super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
   if (value instanceof DefaultMutableTreeNode) {
     value = ((DefaultMutableTreeNode) value).getUserObject();
     if (value instanceof File) {
       File file = (File) value;
       if (file.isFile()) {
         this.setIcon(this.fsv.getSystemIcon(file));
         this.setText(file.getName());
       } else {
         this.setIcon(this.fsv.getSystemIcon(file));
         this.setText(file.getName());
       }
     }
   }
   return this;
 }
コード例 #13
0
 @Override
 public Component getTreeCellEditorComponent(
     JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
   // JLabel l = (JLabel)renderer.getTreeCellRendererComponent(tree, value, selected, expanded,
   // leaf, row, hasFocus);
   JLabel l =
       (JLabel)
           renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, true);
   l.setFont(tree.getFont());
   if (value instanceof DefaultMutableTreeNode) {
     this.setEnabled(tree.isEnabled());
     this.setFont(tree.getFont());
     Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
     if (userObject instanceof CheckBoxNode) {
       CheckBoxNode node = (CheckBoxNode) userObject;
       if (node.status == Status.INDETERMINATE) {
         setIcon(new IndeterminateIcon());
       } else {
         setIcon(null);
       }
       l.setText(node.label);
       setSelected(node.status == Status.SELECTED);
       str = node.label;
     }
     // panel.add(this, BorderLayout.WEST);
     panel.add(l);
     return panel;
   }
   return l;
 }
コード例 #14
0
ファイル: SearchMDIWindow.java プロジェクト: casegenie/Genie
 @Override
 public Component getTreeCellRendererComponent(
     JTree tree,
     Object value,
     boolean sel,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
   if (value instanceof FileNode) {
     FileNode fn = (FileNode) value;
     setIcon(fileTypeIcons[FileType.getByFileName(fn.getSh().getPath()).id()]);
     if (sel) {
       setForeground(Color.white);
     } else {
       setForeground(
           fn.containedInShare(SearchMDIWindow.this.ui.getCore()) ? Color.gray : Color.black);
     }
   } else if (value instanceof FolderNode) {
     FolderNode fn = (FolderNode) value;
     if (sel) {
       setForeground(Color.white);
     } else {
       setForeground(
           fn.containedInShare(SearchMDIWindow.this.ui.getCore()) ? Color.gray : Color.black);
     }
   }
   return this;
 }
コード例 #15
0
ファイル: StartupManager.java プロジェクト: RickKohrs/mcidasv
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;

      File f = (File) node.getUserObject();
      String path = f.getPath();

      if (f.isDirectory()) {
        setToolTipText("Bundle Directory: " + path);
      } else if (ArgumentManager.isZippedBundle(path)) {
        setToolTipText("Zipped Bundle: " + path);
      } else if (ArgumentManager.isXmlBundle(path)) {
        setToolTipText("XML Bundle: " + path);
      } else {
        setToolTipText("Unknown file type: " + path);
      }
      setText(f.getName().replace(f.getParent(), ""));
      return this;
    }
コード例 #16
0
      public Component getTreeCellRendererComponent(
          JTree tree,
          Object value,
          boolean isSelected,
          boolean isExpanded,
          boolean isLeaf,
          int row,
          boolean hasFocus) {
        isTargetNode = (value == dropTargetNode);
        super.getTreeCellRendererComponent(
            tree, value, isSelected, isExpanded, isLeaf, row, hasFocus);

        if (parentsPathUuid != null) {
          AlfrescoNode alfrescoNode =
              (AlfrescoNode) ((DefaultMutableTreeNode) value).getUserObject();
          if (parentsUuid != null && parentsUuid.contains(alfrescoNode.getUuid())) {
            setTickFolder(isExpanded, isSelected);
          } else if (parentsPathUuid.contains(alfrescoNode.getUuid())) {
            setGreenFolder(isExpanded, isSelected);
          } else {
            setSimpleFolder(isExpanded, isSelected);
          }
        }

        return this;
      }
コード例 #17
0
ファイル: FilesTab.java プロジェクト: conicalflask/fs2
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      if (value instanceof FileSystemEntry) {
        FileSystemEntry fse = (FileSystemEntry) value;
        if (fse.isLoadingNode) {
          setIcon(spinner.getSpinner());
        } else {
          if (fse.isSearch()) {
            setSearch(fse);
          } else {
            if (expanded) {
              setIcon(openIcon);
            } else setIcon(closedIcon);
          }
        }
      } else if (value instanceof FileSystemRoot.SearchesRoot) {
        setSearch((ListableEntry) value);
      } else {
        setIcon(openIcon);
      }
      return this;
    }
コード例 #18
0
ファイル: SwingSpyPanel.java プロジェクト: GistLabs/csss
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
      if (node.getUserObject() != null) {
        ComponentWrapper userObject = (ComponentWrapper) node.getUserObject();
        if (userObject != null) {
          Component c = userObject.component;
          for (int i = 0; i < cmpClasses.length; i++) {
            Class clazz = cmpClasses[i];
            if (clazz.isAssignableFrom(c.getClass())) {
              setIcon(cmpIcons[i]);
              return this;
            }
          }
        }
        setIcon(noneIcon);
      }
      return this;
    }
コード例 #19
0
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    // if root then just return some component
    // it is not shown anyway
    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    if (value instanceof Project) {
      return empty_panel;
    } else if (value instanceof Task) {
      Task t = (Task) value;
      setText(t.getText());
      setToolTipText(t.getDescription());
      setIcon(getStatusIcon(t));
      applyFont(t, this);
      // return getTaskTreeCellRenderer(t, selected, hasFocus);
    } else if (value instanceof Process) {
      Process p = (Process) value;
      setFont(getFont().deriveFont(Font.BOLD));
      setForeground(Color.BLUE);
      setIcon(PROCESS_ICON);
      setText(p.getName());
    } else {
      return empty_panel;
    }

    return this;
  }
コード例 #20
0
ファイル: RootFolder.java プロジェクト: damianham/RIBAX
    /* (non-Javadoc)
     * @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
     */
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {

      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      Folder f = getFolderForNode(value);

      if (f != null) {
        String folderName = f.getTitle();

        if (folderName == null || folderName.length() == 0) {
          folderName = f.getDataItemName();
        }

        if (f.getFolderIcon() != null) {
          setIcon(f.getFolderIcon());
        } else {
          setText(folderName);
        }
        setToolTipText(f.getTooltip());
      } else {
        setToolTipText(null); // no tool tip
      }

      return this;
    }
コード例 #21
0
    // ===============================================================
    // ===============================================================
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object obj,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {

      super.getTreeCellRendererComponent(tree, obj, sel, expanded, leaf, row, hasFocus);

      setBackgroundNonSelectionColor(background);
      setForeground(Color.black);
      setBackgroundSelectionColor(Color.lightGray);
      if (row == 0) {
        //	ROOT
        setFont(fonts[TITLE]);
        setIcon(tango_icon);
      } else {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) obj;

        if (node.getUserObject() instanceof PollThread) {
          setFont(fonts[THREAD]);
          setIcon(class_icon);
        } else {
          setFont(fonts[DEVICE]);
          setIcon(cmd_icon);
        }
      }
      return this;
    }
コード例 #22
0
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean sel,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    JDomNodeAdapter adapterNode = (JDomNodeAdapter) value;

    if (adapterNode.getNode().isRootElement()) {
      value = adapterNode.getNode().getName();
    } else // if(adapterNode.childCount() > 0)
    {
      Attribute att = adapterNode.getNode().getAttribute("name");
      if (att != null) value = adapterNode.getNode().getName() + ": " + att.getValue();
      else value = adapterNode.getNode().getName();
    }

    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

    if (!sel) setColor(adapterNode.getNode());

    return this;
  }
コード例 #23
0
  // {{{ getTreeCellRendererComponent() method
  public final Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    if (!propertyChangeListeners.containsKey(tree)) {
      PropertyChangeListener propertyChangeListener =
          new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              if (!(evt.getSource() instanceof JTree)) return;

              JTree tree = (JTree) evt.getSource();
              if (tree.getCellRenderer() == EnhancedTreeCellRenderer.this)
                tree.setCellRenderer(newInstance());

              tree.removePropertyChangeListener("UI", propertyChangeListeners.remove(tree));
            }
          };
      tree.addPropertyChangeListener("UI", propertyChangeListener);
      propertyChangeListeners.put(tree, propertyChangeListener);
    }

    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

    configureTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

    return this;
  } // }}}
コード例 #24
0
  public GoodsTopComponent() {

    builder = new GoodsTreeBuilder();
    groupModel = builder.buildGroupTree();
    complexModel = builder.buidComplexTree();

    initComponents();
    setName(Bundle.CTL_GoodsTopComponent());
    setToolTipText(Bundle.HINT_GoodsTopComponent());

    complexTreeTable.setTreeTableModel(complexModel);

    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(new ImageIcon(getClass().getResource("folder_close_16.png")));
    renderer.setOpenIcon(new ImageIcon(getClass().getResource("folder_open_16.png")));
    renderer.setClosedIcon(new ImageIcon(getClass().getResource("folder_close_16.png")));
    groupTree.setCellRenderer(renderer);
  }
コード例 #25
0
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof DefaultMutableTreeNode) {
        Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
        Icon icon = null;
        if (userObject instanceof Group) {
          Group group = (Group) userObject;
          String name = group.getName();
          setText(name != null ? name : group.getId());
          icon = group.getIcon();
          if (icon == null) {
            icon = getClosedIcon();
          }
        } else if (userObject instanceof String) {
          String actionId = (String) userObject;
          AnAction action = ActionManager.getInstance().getAction(actionId);
          String name = action != null ? action.getTemplatePresentation().getText() : null;
          setText(!StringUtil.isEmptyOrSpaces(name) ? name : actionId);
          if (action != null) {
            Icon actionIcon = action.getTemplatePresentation().getIcon();
            if (actionIcon != null) {
              icon = actionIcon;
            }
          }
        } else if (userObject instanceof Pair) {
          String actionId = (String) ((Pair) userObject).first;
          AnAction action = ActionManager.getInstance().getAction(actionId);
          setText(action != null ? action.getTemplatePresentation().getText() : actionId);
          icon = (Icon) ((Pair) userObject).second;
        } else if (userObject instanceof Separator) {
          setText("-------------");
        } else if (userObject instanceof QuickList) {
          setText(((QuickList) userObject).getDisplayName());
          icon = AllIcons.Actions.QuickList;
        } else {
          throw new IllegalArgumentException("unknown userObject: " + userObject);
        }

        setIcon(ActionsTree.getEvenIcon(icon));

        if (sel) {
          setForeground(UIUtil.getTreeSelectionForeground());
        } else {
          setForeground(UIUtil.getTreeForeground());
        }
      }
      return this;
    }
コード例 #26
0
  /**
   * DOCUMENT ME!
   *
   * @param tree DOCUMENT ME!
   * @param value DOCUMENT ME!
   * @param selected DOCUMENT ME!
   * @param expanded DOCUMENT ME!
   * @param leaf DOCUMENT ME!
   * @param row DOCUMENT ME!
   * @param hasFocus DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  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);

    return panel;
  }
コード例 #27
0
 @Override
 public Component getTreeCellRendererComponent(
     JTree tree, Object value, boolean sel, boolean exp, boolean leaf, int row, boolean hasFocus) {
   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
   boolean owner;
   if (node.getUserObject() instanceof String) {
     switch ((String) node.getUserObject()) {
       case LobbyUI.TREE_CONNECTED_USERS:
         setIcon(serverIcon);
         setOpenIcon(serverIcon);
         setClosedIcon(serverIcon);
         setDisabledIcon(serverIcon);
         setLeafIcon(serverIcon);
         break;
       case LobbyUI.TREE_IN_GAME:
         setIcon(gameIcon);
         setOpenIcon(gameIcon);
         setClosedIcon(gameIcon);
         setDisabledIcon(gameIcon);
         setLeafIcon(gameIcon);
         break;
       case LobbyUI.TREE_IN_QUEUE:
         setIcon(queueIcon);
         setOpenIcon(queueIcon);
         setClosedIcon(queueIcon);
         setDisabledIcon(queueIcon);
         setLeafIcon(queueIcon);
         break;
       case LobbyUI.TREE_IN_LOBBY:
         setIcon(lobbyIcon);
         setOpenIcon(lobbyIcon);
         setClosedIcon(lobbyIcon);
         setDisabledIcon(lobbyIcon);
         setLeafIcon(lobbyIcon);
         break;
     }
   } else {
     owner = ((ClientInformation) node.getUserObject()).ownsGame;
     if (owner) {
       setIcon(hostIcon);
       setOpenIcon(hostIcon);
       setClosedIcon(hostIcon);
       setLeafIcon(hostIcon);
     } else {
       setIcon(userIcon);
       setOpenIcon(userIcon);
       setClosedIcon(userIcon);
       setLeafIcon(userIcon);
     }
   }
   super.getTreeCellRendererComponent(tree, value, sel, exp, leaf, row, hasFocus);
   return this;
 }
コード例 #28
0
 /**
  * base interaction with list: renderer uses list's unselected custom colors.
  *
  * <p>currently, this test fails because the assumptions are wrong! Core renderer behaves slightly
  * unexpected.
  */
 public void testTreeRendererExtTreeColors() {
   Color background = Color.MAGENTA;
   Color foreground = Color.YELLOW;
   tree.setBackground(background);
   tree.setForeground(foreground);
   coreTreeRenderer.setBackgroundNonSelectionColor(background);
   coreTreeRenderer.setTextNonSelectionColor(foreground);
   // prepare standard
   Component coreComponent =
       coreTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // sanity: known standard behaviour
   // background is manually painted
   assertEquals(background, coreComponent.getBackground());
   assertEquals(tree.getForeground(), coreComponent.getForeground());
   // prepare extended
   Component xComponent =
       xTreeRenderer.getTreeCellRendererComponent(tree, null, false, false, false, 0, false);
   // assert behaviour same as standard
   assertEquals(background, xComponent.getBackground());
   assertEquals(foreground, xComponent.getForeground());
 }
コード例 #29
0
 public Component getTreeCellRendererComponent(
     JTree pTree,
     Object pValue,
     boolean pSel,
     boolean pExpanded,
     boolean pLeaf,
     int pRow,
     boolean pHasFocus) {
   super.getTreeCellRendererComponent(pTree, pValue, pSel, pExpanded, pLeaf, pRow, pHasFocus);
   formatNode((DefaultMutableTreeNode) pValue, pTree);
   return this;
 }
コード例 #30
0
 @Override
 public java.awt.Component getTreeCellRendererComponent(
     JTree tree,
     Object value,
     boolean selected,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   super.getTreeCellRendererComponent(
       tree, getNombreTorneo(value), leaf, expanded, leaf, row, hasFocus);
   return this;
 }