當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。