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


Java DefaultTreeCellRenderer.setClosedIcon方法代码示例

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


在下文中一共展示了DefaultTreeCellRenderer.setClosedIcon方法的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: init

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public void init(String filename, StringBuilder sourcecode, boolean createComponents)
   {
usedProductionsStack= new Stack<DefaultMutableTreeNode>();
usedProductionsStackRoot= new StacktraceTreeNode("Call stack of: " + filename, currentFrame);
usedProductionsStack.push(usedProductionsStackRoot);
if (createComponents)
{
    stacktraceTree= new JTree();
    DefaultTreeCellRenderer renderer= new DefaultTreeCellRenderer();
    Icon customOpenIcon= new ImageIcon(HumoTester.class.getResource("/images/stckframe.gif"));
    Icon customClosedIcon= new ImageIcon(HumoTester.class.getResource("/images/stckframe.gif"));
    renderer.setOpenIcon(customOpenIcon);
    renderer.setClosedIcon(customClosedIcon);
    stacktraceTree.setCellRenderer(renderer);
}

stacktraceTree.setModel(new DefaultTreeModel(usedProductionsStackRoot));
currentFrame= null;
   }
 
开发者ID:fpetrola,项目名称:humo,代码行数:20,代码来源:CallStackParserListener.java

示例6: init

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public void init(String filename, boolean createComponents)
   {
nodes= new HashMap<CharSequence, DefaultMutableTreeNode>();
this.root= new DefaultMutableTreeNode("Productions of: " + filename);

if (createComponents)
{
    productionsTree= new JTree(root);
    DefaultTreeCellRenderer renderer= new DefaultTreeCellRenderer();
    Icon customOpenIcon= new ImageIcon(HumoTester.class.getResource("/images/scalarvar.gif"));
    Icon customClosedIcon= new ImageIcon(HumoTester.class.getResource("/images/genericvariable.gif"));
    renderer.setOpenIcon(customOpenIcon);
    renderer.setClosedIcon(customClosedIcon);
    productionsTree.setCellRenderer(renderer);
}

productionsTree.setModel(new DefaultTreeModel(root));
   }
 
开发者ID:fpetrola,项目名称:humo,代码行数:19,代码来源:ProductionsParserListener.java

示例7: init

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public void init(String filename, boolean createComponents, CharSequence sourcecode)
   {
nodes= new Stack<DefaultMutableTreeNode>();
root= new DefaultMutableTreeNode("Execution of: " + filename);
nodes.push(root);
if (createComponents)
{
    executionTree= new JTree();
    DefaultTreeCellRenderer renderer= new DefaultTreeCellRenderer();
    Icon customOpenIcon= new ImageIcon(HumoTester.class.getResource("/images/ebrkpnt_green.gif"));
    Icon customClosedIcon= new ImageIcon(HumoTester.class.getResource("/images/ebrkpnt.gif"));
    renderer.setOpenIcon(customOpenIcon);
    renderer.setClosedIcon(customClosedIcon);
    executionTree.setCellRenderer(renderer);

}

executionTree.setModel(new DefaultTreeModel(root));
   }
 
开发者ID:fpetrola,项目名称:humo,代码行数:20,代码来源:ExecutionParserListener.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

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