本文整理汇总了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
}
}
示例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");
}