本文整理汇总了Java中javax.swing.tree.DefaultTreeCellRenderer.setOpenIcon方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeCellRenderer.setOpenIcon方法的具体用法?Java DefaultTreeCellRenderer.setOpenIcon怎么用?Java DefaultTreeCellRenderer.setOpenIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeCellRenderer
的用法示例。
在下文中一共展示了DefaultTreeCellRenderer.setOpenIcon方法的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));
}
示例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);
}
示例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"));
}
示例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);
}
示例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;
}
示例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));
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
});
}
示例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);
}
示例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());
}
示例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);
}