After some elaboration, it's easy if one know how to do it - as obvious...
Whole solution for others:
I have class in which I'm using JXTable:
JXTable myTable = new JXTable(new MyTableModel())
...use_table_as_usually...
class for the table:
public class MyTable extends JXTable{
public MyTable(AbstractTableModel model){
super(model);
//remove items for horizontal scrollbar, pack and packall
this.getActionMap().remove("column.horizontalScroll");
this.getActionMap().remove("column.packAll");
this.getActionMap().remove("column.packSelected");
//first two columns should be shown permanently
ColumnControlButton controlButton = new ColumnControlButton(this){
@Override
protected ColumnControlPopup createColumnControlPopup(){
return (new NFColumnControlPopup());
}
class NFColumnControlPopup extends DefaultColumnControlPopup{
@Override
public void addVisibilityActionItems(List<? extends AbstractActionExt> actions){
for(int i = 0; i < actions.size(); i++){
AbstractActionExt action = actions.get(i);
JCheckBoxMenuItem chk = new JCheckBoxMenuItem(action);
chk.setUI(new KeepOpenCheckBox());
//disable first two items but they will be still shown greyed
if(i == 0 || i == 1){
chk.setEnabled(false);
chk.setSelected(false);
}
else{
chk.setEnabled(true);
chk.setSelected(true);
}
chk.addItemListener(action);
super.addItem(chk);
}
}
}
};
this.setColumnControl(controlButton);
}
}
and finaly custom class to keep ColumnControlPopup
open:
public class KeepOpenCheckBox extends BasicCheckBoxMenuItemUI{
public static ComponentUI createUI(JComponent c){
return new KeepOpenCheckBox();
}
protected void doClick(MenuSelectionManager msm){
menuItem.doClick(0);
}
}
That's all. In this example are mixed 3 things:
-how to remove unwanted items for horizontal scrollbar, pack and packall;
-how to disable some column controls from ColumnControlPopup
but keep them showed with grey and without check mark;
-how to keep ColumnControlPopup
open after click on JCheckBoxMenuItem
;
Solution is based on some resources I have found around on the Internet but some informations was old or not working (works in JMenu
but no in popup menu).