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


Java DefaultTreeCellRenderer.setLeafIcon方法代码示例

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


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

示例1: updateIcons

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public static void updateIcons(JTree tree) {
    Font defaultFont = UIManager.getFont("Tree.font");
    Font currentFont = tree.getFont();

    double newScale = (double)
            currentFont.getSize2D() / defaultFont.getSize2D();

    DefaultTreeCellRenderer renderer =
            (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setOpenIcon(
            scale(UIManager.getIcon("Tree.openIcon"), newScale, tree));
    renderer.setClosedIcon(
            scale(UIManager.getIcon("Tree.closedIcon"), newScale, tree));
    renderer.setLeafIcon(
            scale(UIManager.getIcon("Tree.leafIcon"), newScale, tree));

    Collection<Integer> iconSizes = Arrays.asList(
            renderer.getOpenIcon().getIconHeight(),
            renderer.getClosedIcon().getIconHeight(),
            renderer.getLeafIcon().getIconHeight());

    // Convert points to pixels
    Point2D p = new Point2D.Float(0, currentFont.getSize2D());
    FontRenderContext context =
            tree.getFontMetrics(currentFont).getFontRenderContext();
    context.getTransform().transform(p, p);
    int fontSizeInPixels = (int) Math.ceil(p.getY());

    tree.setRowHeight(
            Math.max(fontSizeInPixels, Collections.max(iconSizes) + 2));
}
 
开发者ID:phweda,项目名称:MFM,代码行数:32,代码来源:SwingUtils.java

示例2: CTagFilterTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Creates a new filter tree object.
 * 
 * @param tagManager Provides the tags the user can select.
 */
public CTagFilterTree(final ITagManager tagManager) {
  super(new CFilterTreeModel(tagManager.getRootTag()));

  m_tagManager = tagManager;

  setDigIn(false);

  final DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  renderer.setOpenIcon(ICON_CONTAINER_TAG);
  renderer.setClosedIcon(ICON_CONTAINER_TAG);
  renderer.setLeafIcon(ICON_TAG);
  setCellRenderer(renderer);

  setRootVisible(false);
  TreeHelpers.expandAll(this, true);

  tagManager.addListener(m_tagManagerListener);
}
 
开发者ID:google,项目名称:binnavi,代码行数:24,代码来源:CTagFilterTree.java

示例3: Workspace

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Constructor
 */
Workspace()
{
	super(new BorderLayout());
	add(new JScrollPane(variablesTree), BorderLayout.CENTER);
	setPreferredSize(new Dimension(200, 300));
	variablesTree.setRootVisible(false);
	variablesTree.setShowsRootHandles(true);
	
	// Customize icons
	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	Icon leafIcon = ImageLoadingTools.getResourceIcon("icons/sticky-note-pin.png", "document");
	if(leafIcon != null)
		renderer.setLeafIcon(leafIcon);
	Icon openIcon = ImageLoadingTools.getResourceIcon("icons/wooden-box.png", "opened folder");
	if(openIcon != null)
		renderer.setOpenIcon(openIcon);
	Icon closedIcon = ImageLoadingTools.getResourceIcon("icons/wooden-box.png", "closed folder");
	if(closedIcon != null)
		renderer.setClosedIcon(closedIcon);
	variablesTree.setCellRenderer(renderer);
	
	setBorder(new TitledBorder("Workspace"));
}
 
开发者ID:langmo,项目名称:youscope,代码行数:27,代码来源:Workspace.java

示例4: initialiseOWLView

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
@Override
protected void initialiseOWLView() throws Exception {
	treeExplanations = new JTree(model);
	treeExplanations.setRowHeight(-1);
	treeExplanations.setRootVisible(true);
	treeExplanations.setShowsRootHandles(true);

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	renderer.setLeafIcon(null);
	treeExplanations.setCellRenderer(renderer);

	setLayout(new BorderLayout());
	add(BorderLayout.CENTER, new JScrollPane(treeExplanations));

	treeExplanations.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

	treeExplanations.addTreeSelectionListener(treeSelectionListener);
	ACETextManager.addSnippetListener(snippetListener);
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:22,代码来源:ACEExplanationViewComponent.java

示例5: GenealogyTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public GenealogyTree(Person graphNode) {
    super(new GenealogyModel(graphNode));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    Icon personIcon = null;
    renderer.setLeafIcon(personIcon);
    renderer.setClosedIcon(personIcon);
    renderer.setOpenIcon(personIcon);
    setCellRenderer(renderer);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:GenealogyTree.java

示例6: RuleTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/** Creates an instance for a given simulator. */
public RuleTree(RuleDisplay display) {
    super(display);
    // the following is the easiest way to ensure that changes in
    // tree labels will be correctly reflected in the display
    // A cleaner way is to invoke DefaultTreeModel.nodeChanged,
    // but how are we supposed to know when this occurs?
    setLargeModel(true);
    setRootVisible(false);
    setShowsRootHandles(true);
    setEnabled(false);
    setToggleClickCount(0);
    setCellRenderer(new DisplayTreeCellRenderer(this));
    getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    // set icons
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) this.cellRenderer;
    renderer.setLeafIcon(Icons.GRAPH_MATCH_ICON);
    this.topDirectoryNode = new DisplayTreeNode();
    this.ruleDirectory = new DefaultTreeModel(this.topDirectoryNode, true);
    setModel(this.ruleDirectory);
    // set key bindings
    ActionMap am = getActionMap();
    am.put(Options.BACK_ACTION_NAME, getActions().getBackAction());
    am.put(Options.FORWARD_ACTION_NAME, getActions().getForwardAction());
    InputMap im = getInputMap();
    im.put(Options.BACK_KEY, Options.BACK_ACTION_NAME);
    im.put(Options.FORWARD_KEY, Options.FORWARD_ACTION_NAME);
    // add tool tips
    installListeners();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:31,代码来源:RuleTree.java

示例7: resetTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Initializes a tree for this tree table.
 */
public JTree resetTree(TreeTableModel treeTableModel) {
    tree = new TreeTableCellRenderer(treeTableModel);

    // Install a tableModel representing the visible rows in the tree.
    super.setModel(new TreeTableModelAdapter(treeTableModel, tree));

    // Force the JTable and JTree to share their row selection models.
    ListToTreeSelectionModelWrapper selectionWrapper = new
        ListToTreeSelectionModelWrapper();
    tree.setSelectionModel(selectionWrapper);
    setSelectionModel(selectionWrapper.getListSelectionModel());

    // Make the tree and table row heights the same.
    if (tree.getRowHeight() < 1) {
        // Metal looks better like this.
        setRowHeight(18);
    }

    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
    setShowGrid(true);
    setIntercellSpacing(new Dimension(1,1));
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)tree.getCellRenderer();
    r.setOpenIcon(null);
    r.setClosedIcon(null);
    r.setLeafIcon(null);
    return tree;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:35,代码来源:SwingGui.java

示例8: changeTreeIcons

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Update the tree small icons: expanded/collapsed/leaf.
 */
private void changeTreeIcons() {
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setClosedIcon(Icons.CLOSED_ICON_16X16);
    renderer.setOpenIcon(Icons.OPEN_ICON_16X16);
    renderer.setLeafIcon(Icons.LEAF_ICON_16X16);
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:10,代码来源:DynamicTree.java

示例9: createNoImageTreeCellRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private TreeCellRenderer createNoImageTreeCellRenderer() {
	DefaultTreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer();
	treeCellRenderer.setLeafIcon(null);
	treeCellRenderer.setOpenIcon(null);
	treeCellRenderer.setClosedIcon(null);
	return treeCellRenderer;
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:8,代码来源:DesignerFx.java

示例10: DataSourcesTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public DataSourcesTree() {
    nodeRoot = new DefaultMutableTreeNode("Datasets");

    for (String serverName : DataSources.getServers()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(new Item(serverName, DataSources.getServerSetting(serverName, "label")));
        nodes.put(serverName, node);
        nodeRoot.add(node);
    }

    setModel(new DefaultTreeModel(nodeRoot));
    // setRootVisible(false);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) getCellRenderer();
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    renderer.setLeafIcon(null);

    setSelectionModel(new OneLeafTreeSelectionModel());
    ToolTipManager.sharedInstance().registerComponent(this);
    SearchableUtils.installSearchable(this).setRecursive(true);

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            TreePath path;
            if (e.getClickCount() == 2 && getRowForLocation(e.getX(), e.getY()) != -1 && (path = getPathForLocation(e.getX(), e.getY())) != null) {
                Object obj = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
                if (obj instanceof SourceItem)
                    ObservationDialog.getInstance().loadButtonPressed();
            }
        }
    });
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:34,代码来源:DataSourcesTree.java

示例11: MidiInstrumentsPane

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
MidiInstrumentsPane() {
	actionEditInstrument.putValue(Action.SMALL_ICON, Res.iconEdit16);
	actionRemove.putValue(Action.SMALL_ICON, Res.iconDelete16);
	
	removeAll();
	
	tbInstruments.add(btnAddInstrument);
	tbInstruments.add(btnEditInstrument);
	tbInstruments.add(btnRemoveInstrument);
	
	Dimension d;
	d = new Dimension(Short.MAX_VALUE, tbInstruments.getPreferredSize().height);
	tbInstruments.setMaximumSize(d);
	tbInstruments.setFloatable(false);
	
	add(tbInstruments, BorderLayout.NORTH);
	JScrollPane sp = new JScrollPane(midiInstrumentTree);
	
	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	renderer.setClosedIcon(Res.iconFolder16);
	renderer.setOpenIcon(Res.iconFolderOpen16);
	renderer.setLeafIcon(Res.iconInstrument16);

	midiInstrumentTree.setCellRenderer(renderer);
	
	JPanel p = new JPanel();
	p.setLayout(new BorderLayout());
	p.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
	
	p.add(sp);
	
	add(p);
	
	setAlignmentX(LEFT_ALIGNMENT);
}
 
开发者ID:lxlxlo,项目名称:LS-jsampler,代码行数:36,代码来源:MidiInstrumentMapsPage.java

示例12: refreshTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private void refreshTree() {
	tree = new JTree(simDir);
	if (!topLevel /*&& learnSpecs == null*/) {
		tree.addMouseListener(this);
	}
	tree.putClientProperty("JTree.icons", makeIcons());
	tree.setCellRenderer(new IconNodeRenderer());
	DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
	renderer.setLeafIcon(MetalIconFactory.getTreeLeafIcon());
	renderer.setClosedIcon(MetalIconFactory.getTreeFolderIcon());
	renderer.setOpenIcon(MetalIconFactory.getTreeFolderIcon());
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:Graph.java

示例13: testIconSetOnRendererFalseOverwrite

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Issue #769-swingx: setXXIcon on renderer vs setXXIcon on Tree/Table.
 * Characterize tree behaviour.
 * 
 * Here: icon on renderer must be respected if overwrite is false.
 */
@Test
public void testIconSetOnRendererFalseOverwrite() {
    JXTree tree = new JXTree();
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(null);
    tree.setCellRenderer(renderer);
    assertEquals("renderer must have null leaf icon", null, renderer.getLeafIcon());
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:15,代码来源:JXTreeUnitTest.java

示例14: testIconSetOnRendererFalseOverwrite

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Issue #769-swingx: setXXIcon on renderer vs setXXIcon on Tree/Table.
 * Characterize treeTable behaviour.
 * 
 * Here: icon on renderer must be respected if overwrite is false.
 */
@Test
public void testIconSetOnRendererFalseOverwrite() {
    JXTreeTable treeTable = new JXTreeTable();
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(null);
    treeTable.setTreeCellRenderer(renderer);
    assertEquals("renderer must have null leaf icon", null, renderer.getLeafIcon());
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:15,代码来源:JXTreeTableUnitTest.java

示例15: GenealogyTree

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public GenealogyTree(Person graphNode) {
    super(new GenealogyModel(graphNode));
    getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    Icon personIcon = null;
    renderer.setLeafIcon(personIcon);
    renderer.setClosedIcon(personIcon);
    renderer.setOpenIcon(personIcon);
    setCellRenderer(renderer);
}
 
开发者ID:plum-umd,项目名称:pasket,代码行数:12,代码来源:GenealogyTree.java


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