本文整理汇总了Java中org.jdesktop.swingx.renderer.DefaultTableRenderer类的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableRenderer类的具体用法?Java DefaultTableRenderer怎么用?Java DefaultTableRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultTableRenderer类属于org.jdesktop.swingx.renderer包,在下文中一共展示了DefaultTableRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interactiveTreeTableLinkRendererSimpleText
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue #??-swingx: hyperlink in JXTreeTable hierarchical column not
* active.
*
*/
public void interactiveTreeTableLinkRendererSimpleText() {
AbstractHyperlinkAction<Object> simpleAction = new AbstractHyperlinkAction<Object>(null) {
@Override
public void actionPerformed(ActionEvent e) {
LOG.info("hit: " + getTarget());
}
};
JXTreeTable tree = new JXTreeTable(new FileSystemModel());
HyperlinkProvider provider = new HyperlinkProvider(simpleAction);
tree.getColumn(2).setCellRenderer(new DefaultTableRenderer(provider));
tree.setTreeCellRenderer(new DefaultTreeRenderer( //provider));
new WrappingProvider(provider)));
// tree.setCellRenderer(new LinkRenderer(simpleAction));
tree.setHighlighters(HighlighterFactory.createSimpleStriping());
JFrame frame = wrapWithScrollingInFrame(tree, "table and simple links");
frame.setVisible(true);
}
示例2: testStringValueRegistryFromColumnFactory
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue 1145-swingx: re-enable filter to use string representation.
* Here: test that cell-location StringValue look up initial per-column renderer
*
*/
@Test
public void testStringValueRegistryFromColumnFactory() {
JXTable table = new JXTable();
final int column = 2;
// custom column factory which sets per-column renderer
ColumnFactory factory = new ColumnFactory() {
@Override
public void configureTableColumn(TableModel model,
TableColumnExt columnExt) {
super.configureTableColumn(model, columnExt);
if (columnExt.getModelIndex() == column)
columnExt.setCellRenderer(new DefaultTableRenderer());
}
};
table.setColumnFactory(factory);
table.setModel(createModelDefaultColumnClasses(4));
StringValueRegistry provider = table.getStringValueRegistry();
assertEquals(table.getCellRenderer(0, column), provider.getStringValue(0, column));
}
示例3: testGetString
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue #767-swingx: consistent string representation.
*
* Here: test api on JXTable.
*/
@Test
public void testGetString() {
JXTable table = new JXTable(new AncientSwingTeam());
StringValue sv = new StringValue() {
@Override
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);
}
};
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
String text = table.getStringAt(0, 2);
assertEquals(sv.getString(table.getValueAt(0, 2)), text);
}
示例4: interactiveRolloverDisabledClickTable
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue #1374-swingx: Rollover click must be disabled if target disabled
*
* Visual test for JXTable, adapted from reporter's test case
*/
public void interactiveRolloverDisabledClickTable() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setEditable(false);
table.setEnabled(false);
final JXFrame frame = showWithScrollingInFrame(table, "disable table must not trigger rollover renderer");
// rollover-enabled default renderer
DefaultTableRenderer renderer = new DefaultTableRenderer() {
@Override
public void doClick() {
JOptionPane.showMessageDialog(frame, "Click");
}
@Override
public boolean isEnabled() {
return true;
}
};
table.setDefaultRenderer(Object.class, renderer);
addEnabledToggle(frame, table);
}
示例5: interactiveToolTipOnTruncatedText
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue 1314: visual interaction of truncated text and tool tip highlighter.
*/
public void interactiveToolTipOnTruncatedText() {
JXTable table = new JXTable(new AncientSwingTeam());
final Icon icon = XTestUtils.loadDefaultIcon();
IconValue iv = new IconValue() {
@Override
public Icon getIcon(Object value) {
return icon;
}
};
table.getColumn(AncientSwingTeam.COLOR_COLUMN).setCellRenderer(new DefaultTableRenderer(StringValues.TO_STRING, iv));
table.addHighlighter(new ToolTipHighlighter(HighlightPredicate.IS_TEXT_TRUNCATED));
JXFrame frame = showWithScrollingInFrame(table, "ToolTip on truncated text");
addComponentOrientationToggle(frame);
}
示例6: interactiveTableHyperlinkNoTooltip
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Table url activation, disabled tooltips.
*/
public void interactiveTableHyperlinkNoTooltip() {
JXTable table = new JXTable(createModelWithLinks());
EditorPaneLinkVisitor visitor = new EditorPaneLinkVisitor();
LinkModelAction<?> action = new LinkModelAction<LinkModel>(visitor) {
@Override
protected void updateFromTarget() {
super.updateFromTarget();
putValue(Action.SHORT_DESCRIPTION, null);
}
};
// set the default renderer for LinkModel - which is basically
// a bean wrapped around an URL
table.setDefaultRenderer(LinkModel.class, new DefaultTableRenderer
(new HyperlinkProvider(action, LinkModel.class)));
JXFrame frame = wrapWithScrollingInFrame(table, visitor.getOutputComponent(), "table and simple links");
frame.setVisible(true);
}
示例7: interactiveTableHyperlinkLFStripingHighlighter
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Check visuals of hyperlink and highlighter.
* Issue #513-swingx: no rollover effect for disabled table.
* Hyperlink is disabled automatically by DefaultVisuals, no need
* to disable the xxRolloverController.
*
*/
public void interactiveTableHyperlinkLFStripingHighlighter() {
EditorPaneLinkVisitor visitor = new EditorPaneLinkVisitor();
final JXTable table = new JXTable(createModelWithLinks());
LinkModelAction<?> action = new LinkModelAction<LinkModel>(visitor);
table.setDefaultRenderer(LinkModel.class, new DefaultTableRenderer
(new HyperlinkProvider(action, LinkModel.class)));
table.setHighlighters(HighlighterFactory.createSimpleStriping());
Action enabled = new AbstractAction("toggle table enabled") {
public void actionPerformed(ActionEvent e) {
table.setEnabled(!table.isEnabled());
}
};
JXFrame frame = wrapWithScrollingInFrame(table, visitor.getOutputComponent(),
"show link renderer in table with LF striping highlighter");
addAction(frame, enabled);
frame.setVisible(true);
}
示例8: interactiveUpdateUIEditors
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* Issue #908-swingx: move updateUI responsibility into column.
*
*/
public void interactiveUpdateUIEditors() {
DefaultTableModel model = new DefaultTableModel(5, 5) {
@Override
public Class<?> getColumnClass(int columnIndex) {
if (getValueAt(0, columnIndex) == null)
return super.getColumnClass(columnIndex);
return getValueAt(0, columnIndex).getClass();
}
};
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(new Date(), i, 0);
model.setValueAt(true, i, 1);
}
JXTable table = new JXTable(model);
TableCellEditor editor = new DatePickerCellEditor();
table.getColumn(0).setCellEditor(editor);
table.getColumn(4).setCellRenderer(new DefaultTableRenderer(new CheckBoxProvider()));
showWithScrollingInFrame(table, "toggle ui - must update editors/renderers");
}
示例9: installRenderers
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的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();
}
示例10: installRenderers
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的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
}
示例11: configureTableColumn
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* {@inheritDoc} <p>
*
* Overridden to set the column's identifier, lookup the title
*/
@Override
public void configureTableColumn(TableModel model,
TableColumnExt columnExt) {
super.configureTableColumn(model, columnExt);
columnExt.setIdentifier(model.getColumnName(columnExt.getModelIndex()));
configureTitle(columnExt);
ComponentProvider<?> provider = getComponentProvider(columnExt.getIdentifier());
if (provider != null) {
columnExt.setCellRenderer(new DefaultTableRenderer(provider));
}
Highlighter highlighter = getHighlighter(columnExt.getIdentifier());
if (highlighter != null) {
columnExt.setHighlighters(highlighter);
}
columnExt.setComparator(getComparator(columnExt.getIdentifier()));
columnExt.setPrototypeValue(getPrototypeValue(columnExt.getIdentifier()));
if (getHiddenNames().contains(columnExt.getIdentifier())) {
columnExt.setVisible(false);
}
}
示例12: PluginInformationPane
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
public PluginInformationPane() {
super();
this.updateModel();
this.setViewportView(this.pluginsTreeTable);
this.pluginsTreeTable.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
this.pluginsTreeTable.getColumnExt(PluginInformationPane.ENABLED_INDEX).setCellEditor(
new BooleanCellEditor()
);
this.pluginsTreeTable.getColumnExt(PluginInformationPane.DOWNLOAD_INDEX).setCellRenderer(
new DefaultTableRenderer(new PluginActionProvider())
);
this.pluginsTreeTable.addHighlighter(new PluginInformationHighlighter());
this.pluginsTreeTable.addMouseListener(new MouseAdapter() {
/* (non-Javadoc)
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
*/
@Override
public void mouseClicked(MouseEvent e) {
PluginInformationPane.this.pluginsTreeTableMouseClicked(e);
}
});
}
示例13: RepositoryInformationPane
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
public RepositoryInformationPane() throws NotInitializedException {
super();
this.setViewportView(this.pluginsTreeTable);
this.updateModel();
this.pluginsTreeTable.getColumnExt(RepositoryInformationPane.DOWNLOAD_INDEX).setCellRenderer(
new DefaultTableRenderer(new PluginActionProvider())
);
this.pluginsTreeTable.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
this.pluginsTreeTable.addHighlighter(new RepositoryHighlighter());
this.pluginsTreeTable.addMouseListener(new MouseAdapter() {
/* (non-Javadoc)
* @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
*/
@Override
public void mouseClicked(MouseEvent e) {
RepositoryInformationPane.this.pluginsTreeTableMouseClicked(e);
}
});
}
示例14: configureTableColumn
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>
*
* Overridden to set the column's identifier, lookup the title
*/
@Override
public void configureTableColumn(TableModel model, TableColumnExt columnExt) {
super.configureTableColumn(model, columnExt);
columnExt.setIdentifier(model.getColumnName(columnExt.getModelIndex()));
configureTitle(columnExt);
ComponentProvider<?> provider = getComponentProvider(columnExt.getIdentifier());
if (provider != null) {
columnExt.setCellRenderer(new DefaultTableRenderer(provider));
}
Highlighter highlighter = getHighlighter(columnExt.getIdentifier());
if (highlighter != null) {
columnExt.setHighlighters(highlighter);
}
columnExt.setComparator(getComparator(columnExt.getIdentifier()));
columnExt.setPrototypeValue(getPrototypeValue(columnExt.getIdentifier()));
if (getHiddenNames().contains(columnExt.getIdentifier())) {
columnExt.setVisible(false);
}
}
示例15: createDefaultRenderers
import org.jdesktop.swingx.renderer.DefaultTableRenderer; //导入依赖的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
}
}