本文整理匯總了Java中org.jdesktop.swingx.JXTable.setColumnFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.setColumnFactory方法的具體用法?Java JXTable.setColumnFactory怎麽用?Java JXTable.setColumnFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.setColumnFactory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTableCopeWithCreateNullColumn
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #564-swingx: allow custom factories to return null column.
* Here: test that table can cope with null columns on create.
*/
@Test
public void testTableCopeWithCreateNullColumn() {
// factory returns null on create
ColumnFactory factory = new ColumnFactory() {
@Override
public TableColumnExt createTableColumn(int modelIndex) {
return modelIndex > 0 ? super.createTableColumn(modelIndex) : null;
}
};
JXTable table = new JXTable();
table.setColumnFactory(factory);
TableModel model = new DefaultTableModel(0, 10);
table.setModel(model);
assertEquals("factory must have created one less than model columns",
model.getColumnCount() - 1, table.getColumnCount());
}
示例2: interactiveNullVisibilityActionWithHideable
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* test if subclasses are allowed to not create a visibility action. This
* might happen, if they want to exempt certain columns from user
* interaction.
*
*/
public void interactiveNullVisibilityActionWithHideable() {
JXTable table = new JXTable();
ColumnControlButton columnControl = new ColumnControlButton(table) {
@Override
protected ColumnVisibilityAction createColumnVisibilityAction(
TableColumn column) {
if (column instanceof TableColumnExt
&& !((TableColumnExt) column).isHideable())
return null;
return super.createColumnVisibilityAction(column);
}
};
table.setColumnControl(columnControl);
table.setColumnControlVisible(true);
ColumnFactory factory = new ColumnFactory() {
/**
* @inherited <p>
*/
@Override
public void configureTableColumn(TableModel model,
TableColumnExt columnExt) {
super.configureTableColumn(model, columnExt);
if (columnExt.getModelIndex() == 0) {
columnExt.setHideable(false);
}
}
};
table.setColumnFactory(factory);
table.setModel(new AncientSwingTeam());
JXFrame frame = wrapWithScrollingInFrame(table,
"first model column not togglable");
frame.setVisible(true);
}
示例3: 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());
}