本文整理汇总了Java中org.jdesktop.swingx.JXTree.setHighlighters方法的典型用法代码示例。如果您正苦于以下问题:Java JXTree.setHighlighters方法的具体用法?Java JXTree.setHighlighters怎么用?Java JXTree.setHighlighters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXTree
的用法示例。
在下文中一共展示了JXTree.setHighlighters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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");
}
示例3: 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);
}
示例4: interactiveColoredTreeWithAlternateRow
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
/**
*
* Effect of background highlighters on tree with custom background. Note:
* background highlighters don't work at all with DefaultTreeCellRenderers.
*/
public void interactiveColoredTreeWithAlternateRow() {
JXTree coreRendering = new JXTree();
coreRendering.setHighlighters(HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
coreRendering.setBackground(ledger);
JXTree tree = new JXTree();
tree.setCellRenderer(new DefaultTreeRenderer());
tree.setHighlighters(HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
tree.setBackground(ledger);
showWithScrollingInFrame(tree, coreRendering, "colored tree with striping: swingx <--> core");
}