本文整理匯總了Java中org.jdesktop.swingx.JXTable.getColumnExt方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getColumnExt方法的具體用法?Java JXTable.getColumnExt怎麽用?Java JXTable.getColumnExt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.getColumnExt方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interactiveTestColumnControlInvisibleColumns
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #192: initially invisibility columns are hidden but marked as
* visible in control.
*
* Issue #38 (swingx): initially invisble columns don't show up in the
* column control list.
*
* Visual check: first enable column control then set column invisible.
*
*/
public void interactiveTestColumnControlInvisibleColumns() {
final JXTable table = new JXTable(new AncientSwingTeam());
table.setColumnControlVisible(true);
final TableColumnExt firstNameColumn = table.getColumnExt("First Name");
firstNameColumn.setVisible(false);
JXFrame frame = wrapWithScrollingInFrame(
table,
"ColumnControl (#192, #38-swingx) first enable ColumnControl then column invisible");
Action toggleHideable = new AbstractActionExt(
"toggle hideable first Name") {
@Override
public void actionPerformed(ActionEvent e) {
firstNameColumn.setHideable(!firstNameColumn.isHideable());
}
};
addAction(frame, toggleHideable);
show(frame);
}
示例2: interactiveTestColumnControlSetModelToggleInvisibleColumns
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #212: programmatically toggle column vis does not work.
*
* Visual check: compare toggle column visibility both via the columnControl
* and programmatically by button. While the columnControl prevents to hide
* the very last visible column, developers have full control to do so
* programatically.
*
*
*/
public void interactiveTestColumnControlSetModelToggleInvisibleColumns() {
final JXTable table = new JXTable();
table.setColumnControlVisible(true);
JXFrame frame = wrapWithScrollingInFrame(table,
"ColumnControl (#212-swingx) setModel and toggle first column invisible");
frame.setVisible(true);
table.setModel(new DefaultTableModel(10, 2));
final TableColumnExt firstNameColumn = table.getColumnExt(1);
Action action = new AbstractAction("Toggle first name visibility") {
@Override
public void actionPerformed(ActionEvent e) {
firstNameColumn.setVisible(!firstNameColumn.isVisible());
}
};
addAction(frame, action);
}
示例3: testColumnVisibilityAction
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* test that the actions synch's its own selected property with
* the column's visible property. <p>
*
* Looks as if the non-synch of action.setSelected only shows
* if the ColumnControlPopup doesn't create a menuitem via ActionFactory: the
* listeners internally installed via ActionFactory probably take care?
* <p>
*
* An analogous test in the incubator (in kleopatra/.../table) did fail
* for a dialog based custom ColumnControlPopup. For now, changed the visibility
* action to explicitly update the tableColumn. All tests are passing,
* but need to further evaluate.
*
*/
@Test
public void testColumnVisibilityAction() {
JXTable table = new JXTable(10, 3);
table.setColumnControlVisible(true);
ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl();
ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0);
TableColumnExt columnExt = table.getColumnExt(0);
boolean visible = columnExt.isVisible();
// sanity
assertTrue(visible);
assertEquals(columnExt.isVisible(), action.isSelected());
action.setSelected(!visible);
// hmmm... here it's working? unexpected
// synch might be done by the listener's installed by ActionFactor.createMenuItem()?
assertEquals(!visible, columnExt.isVisible());
}
示例4: testColumnControlReleaseAction
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
@Test
public void testColumnControlReleaseAction() {
final JXTable table = new JXTable(sortableTableModel);
final TableColumnExt priorityColumn = table.getColumnExt("First Name");
int listenerCount = priorityColumn.getPropertyChangeListeners().length;
table.setColumnControlVisible(true);
// JW: the columnControlButton is created lazily, so we
// have to access to test if listeners are registered.
table.getColumnControl();
assertEquals("numbers of listeners must be increased", listenerCount + 1,
priorityColumn.getPropertyChangeListeners().length);
int totalColumnCount = table.getColumnCount();
table.removeColumn(priorityColumn);
assertEquals("number of columns reduced", totalColumnCount - 1, table.getColumnCount());
assertEquals("all listeners must be removed", 0,
priorityColumn.getPropertyChangeListeners().length);
}
示例5: testPackColumnWithMax
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* test if max parameter is respected.
*
*/
@Test
public void testPackColumnWithMax() {
JXTable table = new JXTable(new AncientSwingTeam());
TableColumnExt columnExt = table.getColumnExt(0);
table.getColumnFactory().packColumn(table, columnExt, -1, -1);
int prefWidth = columnExt.getPreferredWidth();
assertTrue("sanity: ", prefWidth > 10);
int max = prefWidth - 5;
table.getColumnFactory().packColumn(table, columnExt, -1, max);
assertEquals("pref width must be bounded by max",
max, columnExt.getPreferredWidth());
}
示例6: testPackHiddenColumn
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* packColumn can't handle hidden columns.
*
*/
@Test
public void testPackHiddenColumn() {
JXTable table = new JXTable(10, 4);
TableColumnExt columnExt = table.getColumnExt(0);
columnExt.setVisible(false);
try {
table.getColumnFactory().packColumn(table, columnExt, -1, -1);
fail("packColumn is doc'ed to not handle hidden columns");
} catch (IllegalStateException e) {
// expected
}
}
示例7: 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());
}
示例8: testColumnVisibilityActionOnHideable
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
@Test
public void testColumnVisibilityActionOnHideable() {
JXTable table = new JXTable(10, 3);
table.setColumnControlVisible(true);
ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl();
ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0);
TableColumnExt columnExt = table.getColumnExt(0);
// visible property is false
columnExt.setVisible(false);
columnExt.setHideable(false);
assertTrue("visibility action must be selected if not hideable", action.isSelected());
assertFalse("action must be disabled", action.isEnabled());
columnExt.setHideable(true);
assertFalse("visibility action must be unselected if hideable", action.isSelected());
}
示例9: testColumnControlInvisibleColumns
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #192: initially invisibility columns are hidden
* but marked as visible in control.
*
* Issue #38 (swingx): initially invisble columns don't show up
* in the column control list.
*
*
*/
@Test
public void testColumnControlInvisibleColumns() {
final JXTable table = new JXTable(sortableTableModel);
// columns set to invisible before setting the columnControl
// will not be inserted into the column control's list
// table.getColumnExt("Last Name").setVisible(false);
table.setColumnControlVisible(true);
int totalColumnCount = table.getColumnCount();
final TableColumnExt priorityColumn = table.getColumnExt("First Name");
priorityColumn.setVisible(false);
ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl();
assertNotNull("popup menu not null", columnControl.popup);
int columnMenuItems = 0;
Component[] items = ((DefaultColumnControlPopup) columnControl.getColumnControlPopup()).getPopupMenu().getComponents();
for (int i = 0; i < items.length; i++) {
if (!(items[i] instanceof JMenuItem)) {
break;
}
columnMenuItems++;
}
// wrong assumption - has separator and actions!
assertEquals("menu items must be equal to columns", totalColumnCount,
columnMenuItems);
JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ((DefaultColumnControlPopup) columnControl.getColumnControlPopup()).getPopupMenu()
.getComponent(0);
// sanit assert
assertEquals(priorityColumn.getHeaderValue(), menuItem.getText());
assertEquals("selection of menu must be equal to column visibility",
priorityColumn.isVisible(), menuItem.isSelected());
}
示例10: initTableColums
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public static void initTableColums(JXTable table, int width, String... headers) {
for (String caption : headers) {
TableColumnExt columns = table.getColumnExt(caption);
columns.setPreferredWidth(width);
columns.setMaxWidth(width);
columns.setWidth(width);
}
}