本文整理匯總了Java中org.jdesktop.swingx.JXTable.getCellRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getCellRenderer方法的具體用法?Java JXTable.getCellRenderer怎麽用?Java JXTable.getCellRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.getCellRenderer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCellRenderer
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Returns the cell renderer to use for measuring. Delegates to
* JXTable for visible columns, duplicates table logic for hidden
* columns. <p>
*
* @param table the table which provides the renderer
* @param columnExt the TableColumn to configure
*
* @return returns a cell renderer for measuring.
*/
protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) {
int viewIndex = table.convertColumnIndexToView(columnExt
.getModelIndex());
if (viewIndex >= 0) {
// JW: ok to not guard against rowCount < 0?
// technically, the index should be a valid coordinate
return table.getCellRenderer(0, viewIndex);
}
// hidden column - need api on JXTable to access renderer for hidden?
// here we duplicate JXTable api ... maybe by-passing the strategy
// implemented there
TableCellRenderer renderer = columnExt.getCellRenderer();
if (renderer == null) {
renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex()));
}
return renderer;
}
示例2: testPackMargin
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #266-swingx: support customization of pack margin.
*
* added property to ColumnFactory.
*
*/
@Test
public void testPackMargin() {
final int special = 1;
JXTable table = new JXTable(1, 2);
ColumnFactory factory = new ColumnFactory();
table.setColumnFactory(factory);
table.setValueAt("something that's wider than 75", 0, special);
TableColumnExt columnExt = table.getColumnExt(special);
table.packAll();
TableCellRenderer renderer = table.getCellRenderer(0, special);
Component comp = table.prepareRenderer(renderer, 0, special);
int realPrefWidth = 2 * factory.getDefaultPackMargin() // magic value - JXTable's default margin,
// needs to be made configurable, see Issue 266
+ comp.getPreferredSize().width;
// sanity - default margin kicks in
assertEquals(realPrefWidth, columnExt.getPreferredWidth());
int margin = 10;
factory.setDefaultPackMargin(margin);
table.packAll();
table.prepareRenderer(renderer, 0, special);
int otherPrefWidth = 2 * margin + comp.getPreferredSize().width;
assertEquals(otherPrefWidth, columnExt.getPreferredWidth());
}
示例3: testPatternPredicateAllColumns
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1317-swingx: PatternPredicate causes exception with testColumn -1 (ALL)
*
*/
@Test
public void testPatternPredicateAllColumns() {
JXTable table = new JXTable(new AncientSwingTeam());
PatternPredicate predicate = new PatternPredicate(".*e.*");
table.addHighlighter(new ColorHighlighter(predicate, Color.BLUE, null));
for (int i = 0; i < table.getRowCount(); i++) {
for (int j = 0; j < table.getColumnCount(); j++) {
TableCellRenderer renderer = table.getCellRenderer(i, j);
table.prepareRenderer(renderer, i, j);
}
}
}