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


Java JXList.setHighlighters方法代码示例

本文整理汇总了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);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:RolloverVisualCheck.java

示例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");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:64,代码来源:HighlighterClientVisualCheck.java


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