ColumnControlButton extends JButton { protected ColumnControlPopup getColumnControlPopup() { if (popup == null) { popup = createColumnControlPopup(); } return popup; } ColumnControlButton(JXTable table);  ColumnControlButton(JXTable table, Icon icon); @Override void updateUI(); void togglePopup(); boolean getAdditionalActionsVisible(); void setAdditionalActionsVisible(boolean additionalActionsVisible); void setActionGrouper(ActionGrouper grouper); @Override void applyComponentOrientation(ComponentOrientation o); static final String COLUMN_CONTROL_MARKER; static final String COLUMN_CONTROL_BUTTON_ICON_KEY; static final String COLUMN_CONTROL_BUTTON_MARGIN_KEY; }
@Test public void testSetLastColumnMenuItemToUnselected() { 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()); }
@Test public void testColumnControlInvisibleColumns() { final JXTable table = new JXTable(sortableTableModel); 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++; } assertEquals("menu items must be equal to columns", totalColumnCount, columnMenuItems); JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ((DefaultColumnControlPopup) columnControl.getColumnControlPopup()).getPopupMenu() .getComponent(0); assertEquals(priorityColumn.getHeaderValue(), menuItem.getText()); assertEquals("selection of menu must be equal to column visibility", priorityColumn.isVisible(), menuItem.isSelected()); }