当前位置: 首页>>代码示例>>Java>>正文


Java JTree.getCellRenderer方法代码示例

本文整理汇总了Java中javax.swing.JTree.getCellRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.getCellRenderer方法的具体用法?Java JTree.getCellRenderer怎么用?Java JTree.getCellRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTree的用法示例。


在下文中一共展示了JTree.getCellRenderer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextForNodeObject

import javax.swing.JTree; //导入方法依赖的package包/类
private String getTextForNodeObject(JTree tree, Object lastPathComponent) {
    TreeCellRenderer renderer = tree.getCellRenderer();
    if (renderer == null) {
        return null;
    }
    Component c = renderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, 0, false);
    if (c != null && c instanceof JLabel) {
        return ((JLabel) c).getText();
    }
    return lastPathComponent.toString();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:JTreeJavaElement.java

示例2: getCellRenderer

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public TableCellRenderer getCellRenderer(final int row, final int column) {

    JTree tree = (JTree) super.getCellRenderer(row, column);
    DelegatingRenderer rend = ((DelegatingRenderer) tree.getCellRenderer());

    rend.setLeafIcon(leafIcon);
    rend.setOpenIcon(folderIcon);
    rend.setClosedIcon(folderSheetIcon);

    return (TableCellRenderer) tree;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:13,代码来源:QualifierTable.java

示例3: getCellRenderer

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    if (column == 0) {
        JTree tree = (JTree) super.getCellRenderer(row, column);
        DelegatingRenderer rend = ((DelegatingRenderer) tree
                .getCellRenderer());
        TreePath pathForRow = tree
                .getPathForRow(convertRowIndexToModel(row));
        if (pathForRow == null)
            return super.getCellRenderer(row, column);
        BranchView.Node n = (BranchView.Node) pathForRow
                .getLastPathComponent();
        if (n.branch.getBranchId() == branchView.getActualBranch()) {
            rend.setLeafIcon(branchActual);
            rend.setOpenIcon(branchActual);
            rend.setClosedIcon(branchActual);
        } else {
            if (n.branch.getChildren().size() < 2) {
                rend.setLeafIcon(branch);
                rend.setOpenIcon(branch);
                rend.setClosedIcon(branch);
            } else {
                rend.setLeafIcon(branchTree);
                rend.setOpenIcon(branchTree);
                rend.setClosedIcon(branchTree);
            }
        }
    }
    return super.getCellRenderer(row, column);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:31,代码来源:BranchTreeTable.java

示例4: createDocPane

import javax.swing.JTree; //导入方法依赖的package包/类
private JTree createDocPane() {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
        .entrySet()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
        root.add(node);
        for (Object rule : docEntry.getValue()) {
            node.add(new DefaultMutableTreeNode(rule));
        }
    }
    final JTree result = new JTree(root) {
        @Override
        public String getToolTipText(MouseEvent evt) {
            if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
                return null;
            }
            TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
            Object userObject =
                ((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
            return getToolTip(userObject);
        }
    };
    result.setRootVisible(false);
    result.setShowsRootHandles(true);
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(null);
    renderer.setBackgroundSelectionColor(null);
    renderer.setTextSelectionColor(null);
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);
    result.setCellRenderer(renderer);
    ToolTipManager.sharedInstance()
        .registerComponent(result);
    result.addMouseListener(new DismissDelayer(result));
    for (int i = 0; i < root.getChildCount(); i++) {
        result
            .expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
    }
    result.setBackground(null);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:43,代码来源:ControlDisplay.java

示例5: OptionGroupUI

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * The constructor that will add the items to this panel.
 *
 * @param gui The enclosing {@code GUI}.
 * @param group The {@code OptionGroup} encapsulate.
 * @param editable Is the group editable.
 */
public OptionGroupUI(GUI gui, OptionGroup group, boolean editable) {
    super("ReportPanelUI");

    this.gui = gui;
    this.group = group;
    this.editable = editable;

    setLayout(new MigLayout("fill", "[200:]unrelated[550:, grow, fill]",
                            "[top]"));

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(group);
    buildTree(group, root);

    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel) {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(200, super.getPreferredSize().height);
            }
            @Override
            public String convertValueToText(Object value,
                boolean selected, boolean expanded,
                boolean leaf, int row, boolean hasFocus) {
                DefaultMutableTreeNode node
                    = (DefaultMutableTreeNode)value;
                Option option = (Option)node.getUserObject();
                return Messages.getName(option.getId());
            }
        };

    tree.setOpaque(false);
    tree.addTreeSelectionListener(this);
    DefaultTreeCellRenderer renderer
        = (DefaultTreeCellRenderer)tree.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(new Color(0, 0, 0, 1));

    add(tree);
    detailPanel = new MigPanel();
    detailPanel.setLayout(new MigLayout("wrap 2", "[fill]related[fill]"));
    detailPanel.setOpaque(false);
    add(detailPanel, "grow");
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:50,代码来源:OptionGroupUI.java

示例6: installFor

import javax.swing.JTree; //导入方法依赖的package包/类
public static void installFor(JTree tree) {
    TreeSelectionRenderer renderer = (TreeSelectionRenderer) tree.getCellRenderer();
    renderer.install(tree);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:5,代码来源:TreeSelectionRenderer.java


注:本文中的javax.swing.JTree.getCellRenderer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。