use of javax.swing.JCheckBoxMenuItem in project jgnash by ccavanaugh.
the class ActionParser method createMenuItem.
private JMenuItem createMenuItem(final ActionNode node) {
JMenuItem menu;
Action a = actionMap.get(node.idref);
if (node.size() > 0) {
menu = new JMenu(a);
for (int i = 0; i < node.size(); i++) {
ActionNode n = node.getChildAt(i);
if (n.id == null && n.idref == null) {
// detect a separator
((JMenu) menu).addSeparator();
} else {
JMenuItem item = createMenuItem(n);
menu.add(item);
}
}
} else {
if (node.type == null || node.type.isEmpty()) {
menu = new JMenuItem(a);
} else {
switch(node.type) {
case "single":
menu = new JCheckBoxMenuItem(a);
break;
case "toggle":
menu = new JRadioButtonMenuItem(a);
if (node.group != null) {
// create a group
ButtonGroup bGroup;
if (buttonGroups.get(node.group) != null) {
bGroup = buttonGroups.get(node.group);
} else {
bGroup = new ButtonGroup();
buttonGroups.put(node.group, bGroup);
}
bGroup.add(menu);
}
break;
default:
menu = new JMenuItem(a);
break;
}
}
}
menuItemMap.put(node.idref, menu);
// store the idref in the JMenuItem
menu.putClientProperty(ID_REF_ATTRIBUTE, node.idref);
return menu;
}
use of javax.swing.JCheckBoxMenuItem in project GCViewer by chewiebug.
the class GCViewerGuiInternalFrameController method internalFrameOpened.
@Override
public void internalFrameOpened(InternalFrameEvent e) {
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(new WindowMenuItemAction(e));
getMenuBar(e).addToWindowMenuGroup(menuItem);
}
use of javax.swing.JCheckBoxMenuItem in project GCViewer by chewiebug.
the class GCViewerGuiInternalFrameController method updateMenuItemState.
private void updateMenuItemState(InternalFrameEvent e) {
getToolBar(e).getZoomComboBox().setSelectedItem((int) (getSelectedGCDocument(e).getModelChart().getScaleFactor() * 1000.0) + "%");
GCPreferences preferences = getSelectedGCDocument(e).getPreferences();
for (Entry<String, JCheckBoxMenuItem> menuEntry : getMenuBar(e).getViewMenuItems().entrySet()) {
JCheckBoxMenuItem item = menuEntry.getValue();
item.setState(preferences.getGcLineProperty(menuEntry.getKey()));
}
}
use of javax.swing.JCheckBoxMenuItem in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method getOptionsMenu.
private JPopupMenu getOptionsMenu() {
final JPopupMenu menu = new JPopupMenu();
{
final JMenuItem mi = new JCheckBoxMenuItem("Show Legend");
mi.addActionListener(evt -> {
if (legendPanelMediatorProvider.get().getDialog().isVisible()) {
legendPanelMediatorProvider.get().hideDialog();
} else {
CyNetworkView netView = getCurrentEMView();
EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(netView);
legendPanelMediatorProvider.get().showDialog(createStyleOptions(netView), getFilteredDataSets(viewPanel));
}
});
mi.setSelected(legendPanelMediatorProvider.get().getDialog().isVisible());
menu.add(mi);
}
menu.addSeparator();
for (FilterMode mode : FilterMode.values()) {
final JMenuItem mi = new JCheckBoxMenuItem(mode.toString());
mi.addActionListener(evt -> setFilterMode(mode));
mi.setSelected(filterMode == mode);
menu.add(mi);
}
return menu;
}
use of javax.swing.JCheckBoxMenuItem in project zaproxy by zaproxy.
the class TableColumnManager method showPopup.
/*
* Show a popup containing items for all the columns found in the table
* column manager. The popup will be displayed below the table header
* columns that was clicked.
*
* @param index index of the table header column that was clicked
*/
private void showPopup(int index) {
Object headerValue = columnModel.getColumn(index).getHeaderValue();
int columnCount = columnModel.getColumnCount();
JPopupMenu popup = new SelectPopupMenu();
for (TableColumn tableColumn : allColumns) {
Object value = tableColumn.getHeaderValue();
JCheckBoxMenuItem item = new JCheckBoxMenuItem(value.toString());
item.addActionListener(this);
try {
columnModel.getColumnIndex(value);
item.setSelected(true);
if (columnCount == 1) {
item.setEnabled(false);
}
} catch (IllegalArgumentException e) {
item.setSelected(false);
}
popup.add(item);
if (value == headerValue) {
popup.setSelected(item);
}
}
// Display the popup below the TableHeader
JTableHeader header = table.getTableHeader();
Rectangle r = header.getHeaderRect(index);
popup.show(header, r.x, r.height);
}
Aggregations