本文整理汇总了Java中org.jdesktop.swingx.JXList.setHighlighters方法的典型用法代码示例。如果您正苦于以下问题:Java JXList.setHighlighters方法的具体用法?Java JXList.setHighlighters怎么用?Java JXList.setHighlighters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXList
的用法示例。
在下文中一共展示了JXList.setHighlighters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interactiveListRollover
import org.jdesktop.swingx.JXList; //导入方法依赖的package包/类
public void interactiveListRollover() {
final JXList table = new JXList(listModel);
table.setRolloverEnabled(true);
final CompoundHighlighter compoundHighlighter = new CompoundHighlighter(foregroundHighlighter);
table.setHighlighters(compoundHighlighter);
JXFrame frame = wrapWithScrollingInFrame(table, "List 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);
frame.setVisible(true);
}
示例2: interactiveListPatternHighlighterJP
import org.jdesktop.swingx.JXList; //导入方法依赖的package包/类
/**
* Simulates table by one-list per column.
*
* NOTE: the only purpose is to demonstrate the similarity
* of highlighter usage across collection components!
* (shown as example in Javapolis 2007)
*
* @see #interactiveTablePatternHighlighterJP()
*/
public void interactiveListPatternHighlighterJP() {
JXTable source = new JXTable(tableModel);
source.toggleSortOrder(3);
Font font = source.getFont().deriveFont(Font.BOLD | Font.ITALIC);
Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
String pattern = "^M";
PatternPredicate patternPredicate = new PatternPredicate(pattern, 0);
ColorHighlighter magenta = new ColorHighlighter(patternPredicate, null,
Color.MAGENTA, null, Color.MAGENTA);
FontHighlighter derivedFont = new FontHighlighter(patternPredicate,
font);
Highlighter gradient = createRelativeGradientHighlighter(
HorizontalAlignment.LEFT, 0);
Highlighter shading = new ShadingColorHighlighter(
new HighlightPredicate.ColumnHighlightPredicate(0));
// create and configure one JXList per column.
List<JXList> lists = new ArrayList<JXList>();
// first name
JXList list0 = new JXList(createListModel(source, 0));
list0.setHighlighters(simpleStriping);
lists.add(list0);
// last name
JXList list1 = new JXList(createListModel(source, 1));
list1.setHighlighters(simpleStriping, magenta, derivedFont, shading);
lists.add(list1);
// color
JXList listc = new JXList(createListModel(source, 2));
listc.setHighlighters(simpleStriping);
lists.add(listc);
// number
JXList listn = new JXList(createListModel(source, AncientSwingTeam.INTEGER_COLUMN));
listn.setCellRenderer(new DefaultListRenderer(
StringValues.NUMBER_TO_STRING, JLabel.RIGHT));
listn.setHighlighters(simpleStriping, gradient);
lists.add(listn);
// boolean
JXList listb = new JXList(createListModel(source, 4));
listb.setCellRenderer(new DefaultListRenderer(new CheckBoxProvider()));
listb.setFixedCellHeight(list0.getPreferredSize().height
/ source.getRowCount());
listb.setHighlighters(simpleStriping, magenta, derivedFont, gradient);
lists.add(listb);
JComponent panel = Box.createHorizontalBox();
for (JXList l : lists) {
listb.setVisibleRowCount(source.getRowCount());
l.setFont(source.getFont());
panel.add(new JScrollPane(l));
}
showInFrame(panel, "Multiple Highlighters");
}