本文整理汇总了Java中org.jdesktop.swingx.JXTree.setCellRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java JXTree.setCellRenderer方法的具体用法?Java JXTree.setCellRenderer怎么用?Java JXTree.setCellRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXTree
的用法示例。
在下文中一共展示了JXTree.setCellRenderer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interactiveDropOnVisualsTree
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #370-swingx: drop-on not shown correctly.
*
* Check core default renderer as renderer in Table.
*/
public void interactiveDropOnVisualsTree() {
JXTree xTable = new JXTree(AncientSwingTeam.createNamedColorTreeModel());
installTransferHandler(xTable);
xTable.setCellRenderer(new DefaultTreeRenderer());
JTree table = new JTree(xTable.getModel());
installTransferHandler(table);
// xTable.setDropMode(DropMode.USE_SELECTION);
// table.setDropMode(DropMode.USE_SELECTION);
xTable.setDropMode(DropMode.ON_OR_INSERT);
table.setDropMode(DropMode.ON_OR_INSERT);
JXFrame frame = wrapWithScrollingInFrame(xTable, table,
"JXTree <-> core tree: drop-on appearance");
JTextField textField = new JTextField("drag me over first column....");
textField.setDragEnabled(true);
addStatusComponent(frame, textField);
show(frame);
}
示例2: interactiveXTreeLabelFormattingHighlighter
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Custom format on JTree/JXTree (latter with highlighter).
*
*/
public void interactiveXTreeLabelFormattingHighlighter() {
TreeModel model = createComponentHierarchyModel();
JTree tree = new JTree(model);
StringValue converter = new StringValue() {
public String getString(Object value) {
if (value instanceof Component) {
return "Name: " + ((Component) value).getName();
}
return StringValues.TO_STRING.getString(value);
}
};
tree.setCellRenderer(new DefaultTreeRenderer(converter));
JXTree xtree = new JXTree(model);
xtree.setHighlighters(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.RED,
Color.YELLOW));
xtree.setRolloverEnabled(true);
// share renderer
xtree.setCellRenderer(tree.getCellRenderer());
final JXFrame frame = wrapWithScrollingInFrame(tree, xtree, "custom format - tree vs. xtree (+Rollover renderer)");
frame.setVisible(true);
}
示例3: testTreeIconsUpdateUI
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Sanity: icons updated on LF change.
*/
public void testTreeIconsUpdateUI() {
JXTree tree = new JXTree();
DefaultTreeRenderer renderer = new DefaultTreeRenderer();
tree.setCellRenderer(renderer);
WrappingIconPanel before = (WrappingIconPanel) renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
Icon leaf = before.getIcon();
assertNotNull("sanity", leaf);
assertEquals("sanity", UIManager.getIcon("Tree.leafIcon"), leaf);
String lf = UIManager.getLookAndFeel().getName();
setSystemLF(!defaultToSystemLF);
if (lf.equals(UIManager.getLookAndFeel().getName())) {
LOG.info("cannot run test - equal LF" + lf);
return;
}
SwingUtilities.updateComponentTreeUI(tree);
WrappingIconPanel after = (WrappingIconPanel) renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
Icon leafAfter = after.getIcon();
assertNotNull("sanity", leafAfter);
assertFalse("sanity", leaf.equals(leafAfter));
assertEquals("icon must be updated", UIManager.getIcon("Tree.leafIcon"), leafAfter);
}
示例4: interactiveRolloverDisabledClickTree
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #1374-swingx: Rollover click must be disabled if target disabled
*
* Visual test for JXTable, adapted from reporter's test case
*/
public void interactiveRolloverDisabledClickTree() {
JXTree table = new JXTree();
table.setEnabled(false);
table.setRolloverEnabled(true);
final JXFrame frame = showWithScrollingInFrame(table, "disable tree must not trigger rollover renderer");
// rollover-enabled default renderer
DefaultTreeRenderer renderer = new DefaultTreeRenderer() {
@Override
public void doClick() {
JOptionPane.showMessageDialog(frame, "Click");
}
@Override
public boolean isEnabled() {
return true;
}
};
table.setCellRenderer(renderer);
addEnabledToggle(frame, table);
}
示例5: interactiveTreeBorderHighlighter
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Show variants of border Highlighters.
*
*/
public void interactiveTreeBorderHighlighter() {
JXTree tree = new JXTree();
tree.expandAll();
tree.setVisibleRowCount(tree.getRowCount());
// need SwingX highlighter
tree.setCellRenderer(new DefaultTreeRenderer());
tree.setHighlighters(new BorderHighlighter(BorderFactory.createLineBorder(Color.GREEN, 1)));
showWithScrollingInFrame(tree, "Border Highlighters");
}
示例6: interactiveTreeRendererExtendsOpacity
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue swingx-1514: icon background always highlighted. <p>
* Actually a problem introduced by #3789 version of JXPanel
* Not special to the hierarchical nature, same for list
*
* Not fixed (1.6.5) for Nimbus (and potentially other synth-based lafs)
*
* @see org.jdesktop.swingx.renderer.RendererVisualCheck#interactiveIconTextAlignmentAndExtendsOpacity
*/
public void interactiveTreeRendererExtendsOpacity() {
JXTree table = new JXTree();
table.expandAll();
final WrappingProvider wrapper = new WrappingProvider();
table.setCellRenderer(new DefaultTreeRenderer(wrapper));
table.addHighlighter(HighlighterFactory.createSimpleStriping());
JXFrame frame = wrapWithScrollingInFrame(table, "background on icon?");
addAction(frame, createToggleExtendsOpacityAction(wrapper, table));
show(frame);
}
示例7: interactiveTreeURIRenderer
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
public void interactiveTreeURIRenderer() {
JXTree tree = new JXTree(createTreeModelWithURI(20));
tree.setRolloverEnabled(true);
// PENDING JW: how to have "mixed" user object types? HyperlinkAction throws on f.i. String ..
ComponentProvider<?> provider = new HyperlinkProvider(new HyperlinkAction());
tree.setCellRenderer(new DefaultTreeRenderer(new WrappingProvider(provider)));
showWithScrollingInFrame(tree, "tree with uri renderer");
}
示例8: interactiveTestTreeLinkRenderer
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* extended link renderer in tree.
*
*/
public void interactiveTestTreeLinkRenderer() {
EditorPaneLinkVisitor visitor = new EditorPaneLinkVisitor();
JXTree tree = new JXTree(createTreeModelWithLinks(20));
tree.setRolloverEnabled(true);
LinkModelAction<LinkModel> action = new LinkModelAction<LinkModel>(visitor);
ComponentProvider<JXHyperlink> context = new HyperlinkProvider(action, LinkModel.class);
tree.setCellRenderer(new DefaultTreeRenderer(new WrappingProvider(context)));
JFrame frame = wrapWithScrollingInFrame(tree, visitor.getOutputComponent(), "show link renderer in list");
frame.setVisible(true);
}
示例9: interactiveTreeFancyButton
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* PENDING JW: really fancify or remove ;-)
*/
public void interactiveTreeFancyButton() {
JXTree tree = new JXTree();
tree.setRowHeight(30);
MattePainter painter = new MattePainter(Color.YELLOW);
Highlighter hl = new PainterHighlighter(HighlightPredicate.ROLLOVER_ROW, painter);
tree.addHighlighter(hl);
ComponentProvider<?> provider = new NormalButtonProvider(StringValues.TO_STRING, JLabel.LEADING);
tree.setCellRenderer(new DefaultTreeRenderer(provider));
tree.setRolloverEnabled(true);
showWithScrollingInFrame(tree, "Fancy..");
}
示例10: interactiveDropOnWrappingIconPanelTree
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #766-swingx: drop image is blinking over hierarchical column.
*
* Check WrappingIconPanel in tree: blinking. Can't override the validate
* because it's needed to layout the component correctly.
*/
public void interactiveDropOnWrappingIconPanelTree() {
JXTree xTable = new JXTree(new ComponentTreeTableModel(new JXFrame()));
installTransferHandler(xTable);
xTable.setCellRenderer(new DefaultTreeRenderer());
xTable.expandAll();
JXFrame frame = wrapWithScrollingInFrame(xTable,
"Wrapping renderer: blink on drop over?");
JTextField textField = new JTextField("drag me over tree ....");
textField.setDragEnabled(true);
addStatusComponent(frame, textField);
frame.setVisible(true);
}
示例11: interactiveAnimatedIconPainterHighlightTree
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #862-swingx: SwingX rendering components should be PainterAware.
*
* Currently this works only with a local version which has WrappingIconPanel
* implement the PainterAware by delegating to its content delegate.
*/
public void interactiveAnimatedIconPainterHighlightTree() {
TreeModel model = new FileSystemModel();
JXTree tree = new JXTree(model);
tree.setRolloverEnabled(true);
tree.setCellRenderer(new DefaultTreeRenderer(StringValues.FILE_NAME));
ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage("green-orb.png"));
imagePainter.setHorizontalAlignment(HorizontalAlignment.RIGHT);
final RelativePainter<?> painter = new RelativePainter<Component>(imagePainter);
PainterHighlighter iconHighlighter = new PainterHighlighter();
iconHighlighter.setHighlightPredicate(HighlightPredicate.ROLLOVER_ROW);
iconHighlighter.setPainter(painter);
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent e) {
double fraction = painter.getXFactor();
fraction = fraction > 1 ? 0.0 : fraction + 0.1;
painter.setXFactor(fraction);
}
};
tree.addHighlighter(iconHighlighter);
showWithScrollingInFrame(tree,
"Animated highlighter: marching icon on rollover");
Timer timer = new Timer(100, l);
timer.start();
}
示例12: testTreeHyperlinkForeground
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Wrapping provider: hyperlink foreground must be preserved.
*
*/
@Test
public void testTreeHyperlinkForeground() {
JXTree tree = new JXTree(createTreeModelWithLinks(20));
ComponentProvider<JXHyperlink> context = new HyperlinkProvider();
Color foreground = context.rendererComponent.getForeground();
tree.setCellRenderer(new DefaultTreeRenderer(new WrappingProvider(context)));
tree.getCellRenderer().getTreeCellRendererComponent(tree, "something", false, false, false, -1, false);
assertEquals("hyperlink color must be preserved", foreground, context.rendererComponent.getForeground());
}
示例13: interactiveTreeRolloverScroll
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #1193-swingx: rollover state not updated on scrolling/mouseWheel
*
* visualize behaviour on
* - scrolling (with mouse wheel)
* - resizing (added custom actions)
*/
public void interactiveTreeRolloverScroll() {
final JXTree table = new JXTree(new FileSystemModel());
table.setCellRenderer(new DefaultTreeRenderer());
table.setRolloverEnabled(true);
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null));
final JXFrame frame = getResizableFrame(table);
show(frame);
}
示例14: interactiveTreeRollover
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue ??: background highlighter not working in JXTree.
* Not really an issue, works fine with SwingX renderer.
*/
public void interactiveTreeRollover() {
final JXTree table = new JXTree(treeTableModel);
// Note: we need swingx renderer to make some decorations work reliably.
table.setCellRenderer(new DefaultTreeRenderer());
table.setRolloverEnabled(true);
table.setComponentPopupMenu(createPopup());
final CompoundHighlighter compoundHighlighter = new CompoundHighlighter(foregroundHighlighter);
table.setHighlighters(compoundHighlighter);
JTree tree = new JTree(treeTableModel);
tree.setComponentPopupMenu(createPopup());
JXFrame frame = wrapWithScrollingInFrame(table, tree, "JXTree (at left) with rollover");
Action toggleAction = new AbstractAction("toggle foreground/background") {
boolean isBackground;
public void actionPerformed(ActionEvent e) {
if (isBackground) {
compoundHighlighter.addHighlighter(foregroundHighlighter);
compoundHighlighter.removeHighlighter(backgroundHighlighter);
} else {
compoundHighlighter.addHighlighter(backgroundHighlighter);
compoundHighlighter.removeHighlighter(foregroundHighlighter);
}
isBackground = !isBackground;
}
};
addAction(frame, toggleAction);
addMessage(frame, "background highlight not working in JXTree (with core renderer)");
frame.setVisible(true);
}
示例15: interactiveTreeGetStringUsedInFind
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
* Issue #767-swingx: consistent string representation.
*
* used in find/highlight
*/
public void interactiveTreeGetStringUsedInFind() {
JXTree table = new JXTree(AncientSwingTeam.createNamedColorTreeModel());
table.setCellRenderer(new DefaultTreeRenderer(sv));
HighlightPredicate predicate = new PatternPredicate("R/G/B: -2", 2, 2);
table.addHighlighter(new ColorHighlighter(predicate, null, Color.RED));
JXFrame frame = wrapWithScrollingInFrame(table, "Find/Highlight use adapter string value");
addSearchModeToggle(frame);
addMessage(frame, "Press ctrl-F to open search widget");
show(frame);
}