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


Java DefaultListRenderer类代码示例

本文整理汇总了Java中org.jdesktop.swingx.renderer.DefaultListRenderer的典型用法代码示例。如果您正苦于以下问题:Java DefaultListRenderer类的具体用法?Java DefaultListRenderer怎么用?Java DefaultListRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultListRenderer类属于org.jdesktop.swingx.renderer包,在下文中一共展示了DefaultListRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetString

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #767-swingx: consistent string representation.
 * 
 * Here: test api on JXTable.
 */
@Test
public void testGetString() {
    JXList list = new JXList(AncientSwingTeam.createNamedColorListModel());
    StringValue sv = new StringValue() {

        public String getString(Object value) {
            if (value instanceof Color) {
                Color color = (Color) value;
                return "R/G/B: " + color.getRGB();
            }
            return StringValues.TO_STRING.getString(value);
        }
        
    };
    list.setCellRenderer(new DefaultListRenderer(sv));
    String text = list.getStringAt(0);
    assertEquals(sv.getString(list.getElementAt(0)), text);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:24,代码来源:JXListTest.java

示例2: interactiveSelectWithKey

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1438-swingx: key selection doesn't respect StringValue 
 */
public void interactiveSelectWithKey() {
    JXComboBox box = new JXComboBox(new Object[] {"alice", "berta", "carola"});
    StringValue sv = new StringValue() {

        @Override
        public String getString(Object value) {
            String temp = StringValues.TO_STRING.getString(value);
            if (temp.length() > 1) {
                temp = temp.charAt(1) + temp;
            }
            return temp;
        }
        
    };
    
    box.setRenderer(new DefaultListRenderer(sv));
    showInFrame(box, "navigation");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:22,代码来源:JXComboBoxVisualCheck.java

示例3: interactiveSelectionColorsList

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #862-swingx: JXTree - add api for selection colors.
 * Compare with JList repaint behaviour.
 */
public void interactiveSelectionColorsList() {
    final JXList tree = new JXList(new Object[]{"one", "two", "three"});
    // use SwingX renderer which is aware of per-tree selection colors
    tree.setCellRenderer(new DefaultListRenderer());
    final Color uiBackground = tree.getSelectionBackground();
    final Color uiForeground = tree.getSelectionForeground();
    Action toggleSelectionColors = new AbstractAction("toggle selection colors") {
        
        public void actionPerformed(ActionEvent e) {
            if (tree.getSelectionBackground() == uiBackground) {
                tree.setSelectionBackground(Color.BLUE);
                tree.setSelectionForeground(Color.RED);
            } else {
                tree.setSelectionBackground(uiBackground);
                tree.setSelectionForeground(uiForeground);
            }
            
        }
        
    };
    JXFrame frame = wrapWithScrollingInFrame(tree, "selection color property - compare list repaint");
    addAction(frame, toggleSelectionColors);
    show(frame);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:29,代码来源:JXTreeVisualCheck.java

示例4: interactiveRolloverDisabledClickList

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1374-swingx: Rollover click must be disabled if target disabled
 * 
 * Visual test for JXTable, adapted from reporter's test case
 */
public void interactiveRolloverDisabledClickList() {
    JXList table = new JXList(AncientSwingTeam.createNamedColorListModel());
    table.setEnabled(false);
    table.setRolloverEnabled(true);
    final JXFrame frame = showWithScrollingInFrame(table, "disable list must not trigger rollover renderer");
    // rollover-enabled default renderer
    DefaultListRenderer renderer = new DefaultListRenderer() {
        @Override
        public void doClick() {
            JOptionPane.showMessageDialog(frame, "Click");
        }
        
        @Override
        public boolean isEnabled() {
            return true;
        }
    };
    table.setCellRenderer(renderer);
    addEnabledToggle(frame, table);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:RolloverVisualCheck.java

示例5: interactiveListHyperlinkSimpleText

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Simple target action.
 *
 */
public void interactiveListHyperlinkSimpleText() {
    AbstractHyperlinkAction<Object> linkAction = new AbstractHyperlinkAction<Object>(null) {

        public void actionPerformed(ActionEvent e) {
            LOG.info("hit: " + getTarget());
        }
        
    };
    JXList list = new JXList(createTextOnlyListModel(20));
    list.setRolloverEnabled(true);
    list.setCellRenderer(new DefaultListRenderer(
            new HyperlinkProvider(linkAction)));
    JFrame frame = wrapWithScrollingInFrame(list, "show simple link renderer in list");
    frame.setVisible(true);

}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:JXHyperlinkVisualCheck.java

示例6: installRenderers

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Install renderers which use the prepared string representations.
 * Note: this method is called after the binding (aka: attach models)
 * because it installs per-column renderers which in this setup can be done only 
 * after the columns are created. 
 */
private void installRenderers() {
    initStringRepresentation();
    StringValue sv = stringValues.get("name");
    table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(sv));
    list.setCellRenderer(new DefaultListRenderer(sv));
    tree.setCellRenderer(new DefaultTreeRenderer(sv));
    treeTable.setTreeCellRenderer(new DefaultTreeRenderer(sv));
    
    for (int i = 1; i < keys.length; i++) {
        installColumnRenderers(i, new DefaultTableRenderer(stringValues.get(keys[i])));
    }
    // <snip> Unrelated, just for fun: Hyperlink 
    // Use a hyperlinkRenderer for the email column
    HyperlinkProvider provider = new HyperlinkProvider(new ContributorMailAction(
            stringValues.get("email")));
    installColumnRenderers(keys.length - 1, new DefaultTableRenderer(provider));
    table.getColumnExt(keys.length - 1).setToolTipText(
            "Note: the mail-to action will do nothing in security restricted environments");
    // </snip>
    table.packAll();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:HighlighterExtDemo.java

示例7: installRenderers

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Install renderers which use the prepared string representations.
 * Note: this method is called after the binding (aka: attach models)
 * because it installs per-column renderers which in this setup can be done only 
 * after the columns are created. 
 */
// <snip> Custom String Representation
// install SwingX renderers configured with the appropriate String converter
private void installRenderers() {
    StringValue sv = stringValues.get("name");
    table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(sv));
    list.setCellRenderer(new DefaultListRenderer(sv));
    tree.setCellRenderer(new DefaultTreeRenderer(sv));
    treeTable.setTreeCellRenderer(new DefaultTreeRenderer(sv));
    
    for (int i = 1; i < keys.length; i++) {
        installColumnRenderers(i, new DefaultTableRenderer(stringValues.get(keys[i])));
    }
    // </snip>
    // PENDING JW: make the email column use a hyperlinkRenderer once the
    // MatchingTextHighlighter can handle buttons
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:SearchDemo.java

示例8: PainterControl

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
public PainterControl() {
    StringValue effectInfo = DisplayValues.DISPLAY_INFO_DESCRIPTION;
    
    // effects
    effectBox.setRenderer(new DefaultListRenderer(effectInfo));
    effectBox.setModel(createAreaEffectsList());
    styleBox.setModel(
            new EnumComboBoxModel<Style>(Style.class));
    
    // base
    interpolationBox.setModel(
            new EnumComboBoxModel<Interpolation>(Interpolation.class));
    filterBox.setModel(createFilterList());
    filterBox.setRenderer(new DefaultListRenderer(effectInfo));
    
    // layout data
    horizontalAlignmentBox.setModel(
            new EnumComboBoxModel<HorizontalAlignment>(HorizontalAlignment.class));
    verticalAlignmentBox.setModel(
            new EnumComboBoxModel<VerticalAlignment>(VerticalAlignment.class));

}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:PainterDemo.java

示例9: bind

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * bind the components to the patternModel/actions.
 */
@Override
protected void bind() {
    super.bind();
    List<?> matchRules = getPatternModel().getMatchRules();
    // PENDING: map rules to localized strings
    ComboBoxModel model = new DefaultComboBoxModel(matchRules.toArray());
    model.setSelectedItem(getPatternModel().getMatchRule());
    searchCriteria.setModel(model);
    searchCriteria.setAction(getAction(MATCH_RULE_ACTION_COMMAND));
    searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(getLocale())));
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:16,代码来源:JXSearchPanel.java

示例10: updateLocaleState

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void updateLocaleState(Locale locale) {
    // TODO Auto-generated method stub
    super.updateLocaleState(locale);
    searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(locale)));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:10,代码来源:JXSearchPanel.java

示例11: testRendererNotification

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1232-swingx: JXList must fire property change on setCellRenderer.
 * 
 */
@Test
public void testRendererNotification() {
    JXList list = new JXList();
    assertNotNull("sanity: ", list.getCellRenderer());
    // very first setting: fires twice ... a bit annoying but ... waiting for complaints ;-)
    list.setCellRenderer(new DefaultListRenderer());
    PropertyChangeReport report = new PropertyChangeReport(list);
    list.setCellRenderer(new DefaultListRenderer());
    TestUtils.assertPropertyChangeEvent(report, "cellRenderer", null, list.getCellRenderer());
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:15,代码来源:JXListTest.java

示例12: testNextMatchUseString

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1162-swingx: getNextMatch incorrect for non-standard stringValue
 */
@Test
public void testNextMatchUseString() {
    JXList list = new JXList(AncientSwingTeam.createNamedColorListModel(), true);
    list.setCellRenderer(new DefaultListRenderer(sv));
    assertEquals("must not find a match for 'b', all start with 'r'", 
            -1, list.getNextMatch("b", 0, Bias.Forward));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:11,代码来源:JXListTest.java

示例13: testListGetStringUsedInPatternFilter

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1152-swingx: re-enable filtering with single-string-representation.
 * was: Issue #767-swingx: consistent string representation.
 * 
 * Here: test Pattern filtering uses string rep
 */
@Test
public void testListGetStringUsedInPatternFilter() {
    JXList list = new JXList(AncientSwingTeam.createNamedColorListModel(), true);
    list.setCellRenderer(new DefaultListRenderer(sv));
    RowFilter<Object, Integer> filter = RowFilter.regexFilter("R/G/B: -2.*", 0);
    list.setRowFilter(filter);
    assertTrue(list.getElementCount() > 0);
    assertEquals(sv.getString(list.getElementAt(0)), list.getStringAt(0));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:16,代码来源:JXListTest.java

示例14: testStringValueRegistryFromRendererChange

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1152-swingx: re-enable filtering with single-string-representation.
 * was: Issue #767-swingx: consistent string representation.
 * 
 * Here: test updates the sortController on renderer change.
 */
@Test
public void testStringValueRegistryFromRendererChange() {
    JXList list = new JXList(AncientSwingTeam.createNamedColorListModel(), true);
    StringValueRegistry provider = list.getStringValueRegistry();
    list.setCellRenderer(new DefaultListRenderer(sv));
    assertEquals(list.getWrappedCellRenderer(), provider.getStringValue(0, 0));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:14,代码来源:JXListTest.java

示例15: testStringAtUseProvider

import org.jdesktop.swingx.renderer.DefaultListRenderer; //导入依赖的package包/类
/**
 * Issue #1152-swingx: re-enable filtering with single-string-representation.
 * was: Issue #767-swingx: consistent string representation.
 * 
 * Here: test getStringAt use provider (sanity, trying to pull the rag failed
 * during re-enable)
 */
@Test
public void testStringAtUseProvider() {
    JXList list = new JXList(AncientSwingTeam.createNamedColorListModel(), true);
    list.setCellRenderer(new DefaultListRenderer(sv));
    list.getStringValueRegistry().setStringValue(StringValues.TO_STRING, 0);
    assertEquals(StringValues.TO_STRING.getString(list.getElementAt(0)),
            list.getStringAt(0));
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:17,代码来源:JXListTest.java


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