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


Java MappedValue类代码示例

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


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

示例1: createDefaultRenderers

import org.jdesktop.swingx.renderer.MappedValue; //导入依赖的package包/类
/**
 * Creates default cell renderers for <code>Object</code>s,
 * <code>Number</code>s, <code>Date</code>s, <code>Boolean</code>s, 
 * <code>Icon/Image/</code>s and <code>URI</code>s.
 * <p>
 * Overridden to replace all super default renderers with SwingX variants and
 * additionally register a default for <code>URI</code> types. Note: the latter
 * registration will fail silently in headless environments or when the runtime
 * context doesn't support Desktop.
 * 
 * <p>
 * {@inheritDoc}
 * 
 * @see org.jdesktop.swingx.renderer.DefaultTableRenderer
 * @see org.jdesktop.swingx.renderer.ComponentProvider
 */
@Override
protected void createDefaultRenderers() {
    defaultRenderersByColumnClass = new UIDefaults(8, 0.75f);
    // configured default table renderer (internally LabelProvider)
    setDefaultRenderer(Object.class, new DefaultTableRenderer());
    setDefaultRenderer(Number.class, new DefaultTableRenderer(
            StringValues.NUMBER_TO_STRING, JLabel.RIGHT));
    setDefaultRenderer(Date.class, new DefaultTableRenderer(
            StringValues.DATE_TO_STRING));
    // use the same center aligned default for Image/Icon
    TableCellRenderer renderer = new DefaultTableRenderer(new MappedValue(
            StringValues.EMPTY, IconValues.ICON), JLabel.CENTER);
    setDefaultRenderer(Icon.class, renderer);
    setDefaultRenderer(ImageIcon.class, renderer);
    // use a ButtonProvider for booleans
    setDefaultRenderer(Boolean.class, new DefaultTableRenderer(
            new CheckBoxProvider()));
    
    try {
        setDefaultRenderer(URI.class, new DefaultTableRenderer(
                new HyperlinkProvider(new HyperlinkAction())
        ));
    } catch (Exception e) {
        // nothing to do - either headless or Desktop not supported
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:43,代码来源:JXTable.java

示例2: createDefaultRenderers

import org.jdesktop.swingx.renderer.MappedValue; //导入依赖的package包/类
/**
     * Creates default cell renderers for <code>Object</code>s, <code>Number</code>s,  
     * <code>Date</code>s, <code>Boolean</code>s, and <code>Icon/Image/</code>s.
     * <p>
     * Overridden to install SwingX renderers plus hacking around
     * huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
     * <p>
     * {@inheritDoc}
     * 
     * @see org.jdesktop.swingx.renderer.DefaultTableRenderer
     * @see org.jdesktop.swingx.renderer.ComponentProvider
     */
    @Override
    protected void createDefaultRenderers() {
        // super.createDefaultRenderers();
        // This duplicates JTable's functionality in order to make the renderers
        // available in getNewDefaultRenderer(); If JTable's renderers either
        // were public, or it provided a factory for *new* renderers, this would
        // not be needed

        // hack around #6345050 - new UIDefaults()
        // is created with a huge initialCapacity
        // giving a dummy key/value array as parameter reduces that capacity
        // to length/2.
        Object[] dummies = new Object[] { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0,
                7, 0, 8, 0, 9, 0, 10, 0, };
        defaultRenderersByColumnClass = new UIDefaults(dummies);
        defaultRenderersByColumnClass.clear();
        // configured default table renderer (internally LabelProvider)
        setDefaultRenderer(Object.class, new DefaultTableRenderer());
        setDefaultRenderer(Number.class, new DefaultTableRenderer(
                StringValues.NUMBER_TO_STRING, JLabel.RIGHT));
        setDefaultRenderer(Date.class, new DefaultTableRenderer(
                StringValues.DATE_TO_STRING));
        // use the same center aligned default for Image/Icon
        TableCellRenderer renderer  = new DefaultTableRenderer(
                new MappedValue(StringValues.EMPTY, IconValues.ICON), 
                JLabel.CENTER);
        setDefaultRenderer(Icon.class, renderer);
        setDefaultRenderer(ImageIcon.class, renderer);
        // use a ButtonProvider for booleans
        setDefaultRenderer(Boolean.class, new DefaultTableRenderer(
                new CheckBoxProvider()));


//        // standard renderers
//        // Objects
//        setLazyRenderer(Object.class,
//                "javax.swing.table.DefaultTableCellRenderer");
//
//        // Numbers
//        setLazyRenderer(Number.class,
//                "org.jdesktop.swingx.JXTable$NumberRenderer");
//
//        // Doubles and Floats
//        setLazyRenderer(Float.class,
//                "org.jdesktop.swingx.JXTable$DoubleRenderer");
//        setLazyRenderer(Double.class,
//                "org.jdesktop.swingx.JXTable$DoubleRenderer");
//
//        // Dates
//        setLazyRenderer(Date.class, "org.jdesktop.swingx.JXTable$DateRenderer");
//
//        // Icons and ImageIcons
//        setLazyRenderer(Icon.class, "org.jdesktop.swingx.JXTable$IconRenderer");
//        setLazyRenderer(ImageIcon.class,
//                "org.jdesktop.swingx.JXTable$IconRenderer");
//
//        // Booleans
//        setLazyRenderer(Boolean.class,
//                "org.jdesktop.swingx.JXTable$BooleanRenderer");

    }
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:74,代码来源:JXTable.java


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