本文整理匯總了Java中org.jdesktop.swingx.JXTable.setDefaultRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.setDefaultRenderer方法的具體用法?Java JXTable.setDefaultRenderer怎麽用?Java JXTable.setDefaultRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.setDefaultRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interactiveTextAreaRendererTable
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Quick example of using a JTextArea as rendering component and
* dynamically adjust table row height to max pref height of the
* cells in a row.
*
*/
public void interactiveTextAreaRendererTable() {
DefaultTableModel model = new DefaultTableModel(0, 2);
model.addRow(new String[]{"some really, maybe really really long text - "
+ "wrappit .... where needed ", "some really, maybe really really long text - " +
"wrappit .... where needed "});
model.addRow(new String[]{"another really, maybe really really long text - "
+ "with nothing but junk. wrappit .... where needed", "some really, maybe really really long text - " +
"wrappit .... where needed "});
JXTable table = new JXTable(model);
table.setColumnControlVisible(true);
table.setDefaultRenderer(Object.class, new DefaultTableRenderer(new TextAreaProvider()));
table.addHighlighter(HighlighterFactory.createSimpleStriping());
installDynamicRowHeights(table);
showWithScrollingInFrame(table, "textArea as rendering comp");
}
示例2: interactiveTableCustomColorRendererWithHighlighter
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Compare xtable using custom color renderer - standard vs. ext.<p>
* Adds highlighter ... running amok.
*/
public void interactiveTableCustomColorRendererWithHighlighter() {
TableModel model = new AncientSwingTeam();
JXTable xtable = new JXTable(model);
xtable.addHighlighter(
HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
xtable.setDefaultRenderer(Color.class, new ColorRenderer(true));
JXTable table = new JXTable(model);
table.addHighlighter(
HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
TableCellRenderer renderer = createColorRendererExt();
table.setDefaultRenderer(Color.class, renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, table, "JXTable/highlighter: Custom color renderer - standard/ext");
addStatusMessage(frame, "Highlighter hide custom color renderer background for unselected");
frame.setVisible(true);
}
示例3: interactiveTableCustomColorRendererWithHighlighterDontTouch
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Compare xtable using custom color renderer - standard vs. ext.<p>
* Adds highlighter which respects renderer's dont touch.
*/
public void interactiveTableCustomColorRendererWithHighlighterDontTouch() {
TableModel model = new AncientSwingTeam();
JXTable xtable = new JXTable(model);
Highlighter highlighter = createPropertyRespectingHighlighter(
HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
xtable.addHighlighter(highlighter);
xtable.setDefaultRenderer(Color.class, new ColorRenderer(true));
JXTable table = new JXTable(model);
table.addHighlighter(highlighter);
TableCellRenderer renderer = createColorRendererExt();
table.setDefaultRenderer(Color.class, renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, table, "JXTable/highlighter dont-touch: Custom color renderer - standard/ext");
addStatusMessage(frame, "Highlighter doesn't touch custom color renderer visual properties");
frame.pack();
frame.setVisible(true);
}
示例4: interactiveTableAndTreeCustomColorRenderingController
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* xtable/xlist using the same custom component controller.<p>
*
*/
public void interactiveTableAndTreeCustomColorRenderingController() {
TableModel tableModel = new AncientSwingTeam();
ComponentProvider<JLabel> controller = createColorRenderingLabelController();
JXTable xtable = new JXTable(tableModel);
xtable.setDefaultRenderer(Color.class, new DefaultTableRenderer(controller));
TreeModel model = createTreeColorModel();
JTree tree = new JTree(model);
ComponentProvider<?> wrapper = new WrappingProvider(controller); //;createColorRenderingLabelController());
TreeCellRenderer renderer = new DefaultTreeRenderer(wrapper);
tree.setCellRenderer(renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, tree, "JXTable/JXTree: Custom color renderer - sharing the component controller");
addMessage(frame, "share provider in table and in wrappingProvider does not work?");
frame.pack();
frame.setVisible(true);
}
示例5: testHyperlinkProviderForeground
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #840-swingx: hyperlink foreground unreadable for dark selection colors.
*
* Test that selected foreground is same as table.
*
*/
@Test
public void testHyperlinkProviderForeground() {
JXTable table = new JXTable(20, 2);
HyperlinkProvider provider = new HyperlinkProvider();
JXHyperlink hyperlink = provider.getRendererComponent(null);
Color unclicked = hyperlink.getUnclickedColor();
table.setDefaultRenderer(Object.class, new DefaultTableRenderer(provider));
table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
assertEquals("hyperlink foreground set to unclicked", unclicked, hyperlink.getForeground());
table.setRowSelectionInterval(0, 0);
// JW: had been failing before because I forgot to re-prepare :-)
table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
assertEquals("hyperlink foreground set to table's selection foreground",
table.getSelectionForeground(), hyperlink.getForeground());
}
示例6: interactiveRolloverDisabledClickTable
import org.jdesktop.swingx.JXTable; //導入方法依賴的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);
}
示例7: interactiveTableCustomRendererColor
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #258-swingx: Background LegacyHighlighter must not change custom
* foreground.
* <p>
*
* Use SwingX extended default renderer.
*/
public void interactiveTableCustomRendererColor() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
DefaultTableRenderer renderer = new DefaultTableRenderer();
renderer.setForeground(foreground);
renderer.setBackground(background);
table.addHighlighter(HighlighterFactory.createAlternateStriping(Color.WHITE, HighlighterFactory.GENERIC_GRAY));
table.setDefaultRenderer(Object.class, renderer);
JXTable nohighlight = new JXTable(model);
nohighlight.setDefaultRenderer(Object.class, renderer);
showWithScrollingInFrame(table, nohighlight,
"ext: custom colored renderer with bg highlighter <--> shared without highl");
}
示例8: interactiveTableSQLDateTime
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Use formatting from sql date/time classes.
*
*/
public void interactiveTableSQLDateTime() {
Date date = new Date();
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
Timestamp stamp = new Timestamp(date.getTime());
Time time = new Time(date.getTime());
DefaultTableModel model = new DefaultTableModel(1, 5) {
@Override
public Class<?> getColumnClass(int columnIndex) {
if (getRowCount() > 0) {
Object value = getValueAt(0, columnIndex);
if (value != null) {
return value.getClass();
}
}
return super.getColumnClass(columnIndex);
}
};
model.setColumnIdentifiers(new Object[]{"Date - normal", "SQL Date", "SQL Timestamp", "SQL Time", "Date - as time"});
model.setValueAt(date, 0, 0);
model.setValueAt(sqlDate, 0, 1);
model.setValueAt(stamp, 0, 2);
model.setValueAt(time, 0, 3);
model.setValueAt(date, 0, 4);
JXTable table = new JXTable(model);
// right align to see the difference to normal date renderer
DefaultTableRenderer renderer = new DefaultTableRenderer(
new LabelProvider(SwingConstants.RIGHT));
table.setDefaultRenderer(Timestamp.class, renderer);
table.setDefaultRenderer(Time.class, renderer);
table.setDefaultRenderer(java.sql.Date.class, renderer);
// format the given Date as short time
table.getColumnExt(4).setCellRenderer(new DefaultTableRenderer(
new FormatStringValue(DateFormat.getTimeInstance(DateFormat.SHORT))));
showWithScrollingInFrame(table, "normal/sql date formatting");
}
示例9: interactiveTestTableLinkRenderer
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* extended link renderer in table.
*
*/
public void interactiveTestTableLinkRenderer() {
EditorPaneLinkVisitor visitor = new EditorPaneLinkVisitor();
JXTable table = new JXTable(createModelWithLinks());
LinkModelAction<LinkModel> action = new LinkModelAction<LinkModel>(visitor);
ComponentProvider<JXHyperlink> controller = new HyperlinkProvider(action, LinkModel.class);
table.setDefaultRenderer(LinkModel.class, new DefaultTableRenderer(controller));
JXFrame frame = wrapWithScrollingInFrame(table, visitor.getOutputComponent(), "show link renderer in table");
addStatusMessage(frame, "Note: hyperlinks only clickable if !editable");
frame.setVisible(true);
}
示例10: interactiveTableCustomColorRenderer
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Compare xtable using custom color renderer - standard vs. ext.<p>
*
*/
public void interactiveTableCustomColorRenderer() {
TableModel model = new AncientSwingTeam();
JXTable xtable = new JXTable(model);
xtable.setDefaultRenderer(Color.class, new ColorRenderer(true));
JXTable table = new JXTable(model);
TableCellRenderer renderer = createColorRendererExt();
table.setDefaultRenderer(Color.class, renderer);
showWithScrollingInFrame(xtable, table, "JXTable: Custom color renderer - standard/ext");
}
示例11: interactiveTableAndListCustomColorRenderingController
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* xtable/xlist using the same custom component controller.<p>
*
*/
public void interactiveTableAndListCustomColorRenderingController() {
TableModel tableModel = new AncientSwingTeam();
ComponentProvider<JLabel> controller = createColorRenderingLabelController();
JXTable xtable = new JXTable(tableModel);
xtable.setDefaultRenderer(Color.class, new DefaultTableRenderer(controller));
ListModel model = createListColorModel();
JXList list = new JXList(model);
ListCellRenderer renderer = new DefaultListRenderer(controller);
list.setCellRenderer(renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, list, "JXTable/JXList: Custom color renderer - sharing the component controller");
addMessage(frame, "share provider in normally in different comps is okay?");
frame.pack();
frame.setVisible(true);
}
示例12: interactiveTableSortComparableAndStringValue
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1156-swingx: sort must use comparable
*
* visually check that the custom string value for the color column is
* used for sorting.
*/
public void interactiveTableSortComparableAndStringValue() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
JTable core = new JTable(table.getModel());
core.setAutoCreateRowSorter(true);
JXFrame frame = wrapWithScrollingInFrame(table, core, "JXTable <--> JTable: Compare sorting of color column");
show(frame);
}
示例13: interactiveTableGetStringUsedInFind
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #767-swingx: consistent string representation.
*
* used in find/highlight
*/
public void interactiveTableGetStringUsedInFind() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
HighlightPredicate predicate = new PatternPredicate("R/G/B: -2", 2, 2);
table.addHighlighter(new ColorHighlighter(predicate, null, Color.RED));
table.setColumnControlVisible(true);
JXFrame frame = wrapWithScrollingInFrame(table, "Find/Highlight use adapter string value");
addSearchModeToggle(frame);
addMessage(frame, "Press ctrl-F to open search widget");
show(frame);
}
示例14: testTableGetStringUsedInSearch
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #767-swingx: consistent string representation.
*
* Here: test TableSearchable uses getStringXX
*/
@Test
public void testTableGetStringUsedInSearch() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
String text = sv.getString(table.getValueAt(2, 2));
int matchRow = table.getSearchable().search(text);
assertEquals(2, matchRow);
}
示例15: initJTable
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
private void initJTable() {
valueTable = new JXTable();
valueTable.setColumnControlVisible(true);
valueTable.setEditable(false);
valueTable.setDefaultRenderer(Object.class, new TableValueCellRender());
valueTable.setCellSelectionEnabled(true);
valueTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
valueTable.setModel(dataModel);
valueTable.setShowGrid(true);
valueTable.setDragEnabled(false);
valueTable.setSelectionBackground(new Color(214, 217, 223));
valueTable.setVisibleRowCount(20);
pageCtrlPanel.setVisibleRow(20+"");
}