本文整理匯總了Java中org.jdesktop.swingx.JXTable.getColumnControl方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getColumnControl方法的具體用法?Java JXTable.getColumnControl怎麽用?Java JXTable.getColumnControl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.getColumnControl方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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());
}
示例2: testNonStringActionKeys
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #153-swingx: ClassCastException if actionMap key is not a string.
*
*/
@Test
public void testNonStringActionKeys() {
JXTable table = new JXTable();
Action l = new AbstractAction("dummy") {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
};
table.registerKeyboardAction(l , KeyStroke.getKeyStroke("ESCAPE"), JComponent.WHEN_FOCUSED);
table.setColumnControlVisible(true);
table.getColumnControl();
}
示例3: 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);
}
示例4: testColumnVisibilityActionOnHideableInitial
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1573-swingx: !hideable column action must be disabled
* Problem: isn't initially
*/
@Test
public void testColumnVisibilityActionOnHideableInitial() {
JXTable table = new JXTable(10, 3);
// set the first column !hideable
table.getColumnExt(0).setHideable(false);
table.setColumnControlVisible(true);
ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl();
ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0);
assertFalse("action must be disabled initially", action.isEnabled());
}
示例5: 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());
}
示例6: testColumnControlInXTable
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #404-swingx: load column control icon from ui.
* Test that table instantiates the column control with ui icon.
*/
@Test
public void testColumnControlInXTable() {
JXTable table = new JXTable();
ColumnControlButton control = (ColumnControlButton) table.getColumnControl();
assertSame("columnControl must have icon from ui",
UIManager.getIcon(ColumnControlButton.COLUMN_CONTROL_BUTTON_ICON_KEY),
control.getIcon());
}
示例7: testNonStringIdentifier
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #429-swingx: ClassCastException if column identifiers are not
* String type.
*
*/
@Test
public void testNonStringIdentifier() {
JXTable table = new JXTable(0, 2);
table.getColumn(0).setIdentifier(new Object());
table.setColumnControlVisible(true);
table.getColumnControl();
}
示例8: testSetLastColumnMenuItemToUnselected
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #212-swingx:
*
* guarantee that exactly one column is always visible if
* visibility is toggled via the ColumnControl.
*
* Here we deselect the menuitem.
*
*/
@Test
public void testSetLastColumnMenuItemToUnselected() {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
return;
}
final JXTable table = new JXTable(10, 1);
table.setColumnControlVisible(true);
wrapWithScrollingInFrame(table, "");
ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl();
Component[] items = ((DefaultColumnControlPopup) columnControl.getColumnControlPopup()).getPopupMenu().getComponents();
((JMenuItem) items[0]).setSelected(false);
assertEquals(1, table.getColumnCount());
}
示例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());
}