use of javax.swing.JRadioButtonMenuItem in project pmd by pmd.
the class MainFrame method init.
private void init() {
model = new ViewerModel();
model.addViewerModelListener(this);
sourcePanel = new SourceCodePanel(model);
ASTPanel astPanel = new ASTPanel(model);
xPathPanel = new XPathPanel(model);
getContentPane().setLayout(new BorderLayout());
JSplitPane editingPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel);
editingPane.setResizeWeight(0.5d);
JPanel interactionsPane = new JPanel(new BorderLayout());
interactionsPane.add(xPathPanel, BorderLayout.SOUTH);
interactionsPane.add(editingPane, BorderLayout.CENTER);
getContentPane().add(interactionsPane, BorderLayout.CENTER);
JButton compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE"));
compileBtn.setActionCommand(ActionCommands.COMPILE_ACTION);
compileBtn.addActionListener(this);
evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE"));
evalBtn.setActionCommand(ActionCommands.EVALUATE_ACTION);
evalBtn.addActionListener(this);
evalBtn.setEnabled(false);
statusLbl = new JLabel();
statusLbl.setHorizontalAlignment(SwingConstants.RIGHT);
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
btnPane.add(compileBtn);
btnPane.add(evalBtn);
btnPane.add(statusLbl);
getContentPane().add(btnPane, BorderLayout.SOUTH);
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Language");
ButtonGroup group = new ButtonGroup();
jdk13MenuItem = new JRadioButtonMenuItem("JDK 1.3");
jdk13MenuItem.setSelected(false);
group.add(jdk13MenuItem);
menu.add(jdk13MenuItem);
jdk14MenuItem = new JRadioButtonMenuItem("JDK 1.4");
jdk14MenuItem.setSelected(true);
group.add(jdk14MenuItem);
menu.add(jdk14MenuItem);
jdk15MenuItem = new JRadioButtonMenuItem("JDK 1.5");
jdk15MenuItem.setSelected(false);
group.add(jdk15MenuItem);
menu.add(jdk15MenuItem);
jdk16MenuItem = new JRadioButtonMenuItem("JDK 1.6");
jdk16MenuItem.setSelected(false);
group.add(jdk16MenuItem);
menu.add(jdk16MenuItem);
jdk17MenuItem = new JRadioButtonMenuItem("JDK 1.7");
jdk17MenuItem.setSelected(false);
group.add(jdk17MenuItem);
menu.add(jdk17MenuItem);
// PLSQL
plsqlMenuItem = new JRadioButtonMenuItem("PLSQL");
plsqlMenuItem.setSelected(false);
group.add(plsqlMenuItem);
menu.add(plsqlMenuItem);
menuBar.add(menu);
setJMenuBar(menuBar);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
pack();
setSize(800, 600);
setVisible(true);
}
use of javax.swing.JRadioButtonMenuItem in project CheckboxTree by lorebiga.
the class LookAndFeelExample method getLAFMenuBar.
private JMenuBar getLAFMenuBar() {
JMenuBar retVal = new JMenuBar();
// Define and add the drop down menu to the menubar
JMenu lafMenu = new JMenu("Look&Feel");
retVal.add(lafMenu);
// Create and add Radio Buttons as simple menu items to one of the drop
// down menu
JRadioButtonMenuItem radioAction3 = new JRadioButtonMenuItem("System");
radioAction3.setSelected(true);
JRadioButtonMenuItem radioAction1 = new JRadioButtonMenuItem("Metal-default-theme");
JRadioButtonMenuItem radioAction2 = new JRadioButtonMenuItem("Metal-ocean-theme");
JRadioButtonMenuItem radioAction4 = new JRadioButtonMenuItem("CDE/Motif");
JRadioButtonMenuItem radioAction5 = new JRadioButtonMenuItem("GTK");
JRadioButtonMenuItem radioAction6 = new JRadioButtonMenuItem("Nimbus");
// Create a ButtonGroup and add both radio Button to it. Only one radio
// button in a ButtonGroup can be selected at a time.
ButtonGroup bg = new ButtonGroup();
bg.add(radioAction1);
bg.add(radioAction2);
bg.add(radioAction3);
bg.add(radioAction4);
bg.add(radioAction5);
bg.add(radioAction6);
lafMenu.add(radioAction1);
lafMenu.add(radioAction2);
lafMenu.add(radioAction3);
lafMenu.add(radioAction4);
lafMenu.add(radioAction5);
lafMenu.add(radioAction6);
// Add a listener to the New menu item. actionPerformed() method will
// invoked, if user triggered this menu item
radioAction1.addActionListener(this);
radioAction2.addActionListener(this);
radioAction3.addActionListener(this);
radioAction4.addActionListener(this);
radioAction5.addActionListener(this);
radioAction6.addActionListener(this);
return retVal;
}
use of javax.swing.JRadioButtonMenuItem in project masl by xtuml.
the class InstanceViewer method addMenus.
private void addMenus() {
mainMenu = new JMenuBar();
setJMenuBar(mainMenu);
final JMenu fileMenu = new JMenu("File");
mainMenu.add(fileMenu);
final JMenuItem saveItem = new JMenuItem("Save Table...");
final JMenuItem saveRowsItem = new JMenuItem("Save Rows...");
final JMenuItem exitItem = new JMenuItem(new FrameCloseAction(this));
saveItem.addActionListener(new SaveListener());
saveRowsItem.addActionListener(new SaveRowsListener());
fileMenu.add(saveItem);
fileMenu.add(saveRowsItem);
fileMenu.add(exitItem);
final JMenu objectMenu = new JMenu("Object");
mainMenu.add(objectMenu);
final JMenuItem refreshItem = new JMenuItem("Refresh");
refreshItem.addActionListener(new RefreshListener());
refreshItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK));
objectMenu.add(refreshItem);
final JMenuItem cancelItem = new JMenuItem("Cancel Load");
cancelItem.addActionListener(new CancelLoadListener());
cancelItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
objectMenu.add(cancelItem);
if (Capability.RUN_OBJECT_SERVICE.isAvailable()) {
objectMenu.addSeparator();
final ObjectServiceMetaData[] objectServices = meta.getObjectServices();
Arrays.sort(objectServices);
for (final ObjectServiceMetaData objectService : objectServices) {
final JMenuItem item = new JMenuItem("Run " + objectService);
objectMenu.add(item);
item.addActionListener(new ObjectServiceInvoker(objectService));
}
}
if (Capability.FIRE_EVENT.isAvailable()) {
objectMenu.addSeparator();
final EventMetaData[] events = meta.getInstanceEvents();
Arrays.sort(events);
for (final EventMetaData event : events) {
if (event.getType() == EventType.Creation) {
final JMenuItem item = new JMenuItem("Fire " + event);
objectMenu.add(item);
item.addActionListener(new EventInvoker(event));
}
}
}
if (Capability.FIRE_EVENT.isAvailable() && meta.getAssignerStates().length > 0) {
final JMenu assignerMenu = new JMenu("Assigner");
mainMenu.add(assignerMenu);
final EventMetaData[] assignerEvents = meta.getAssignerEvents();
Arrays.sort(assignerEvents);
for (final EventMetaData assignerEvent : assignerEvents) {
final JMenuItem item = new JMenuItem("Fire " + assignerEvent);
assignerMenu.add(item);
item.addActionListener(new EventInvoker(assignerEvent));
}
}
final JMenu viewMenu = new JMenu("View");
mainMenu.add(viewMenu);
final JCheckBoxMenuItem showId = new JCheckBoxMenuItem(new ShowInternalIdAction("Show Internal Id"));
showId.setSelected(s_showInternalId);
table.showInternalId(s_showInternalId);
viewMenu.add(showId);
final JMenuItem fontMenu = new JMenu("Font");
viewMenu.add(fontMenu);
final ButtonGroup group = new ButtonGroup();
final FontChangeListener listener = new FontChangeListener();
for (int f = 6; f < 15; f++) {
final JRadioButtonMenuItem fontButton = new JRadioButtonMenuItem(f + "pt");
group.add(fontButton);
fontMenu.add(fontButton);
fontButton.setActionCommand("" + f);
fontButton.addActionListener(listener);
if (f == s_defaultFontSize) {
fontButton.setSelected(true);
}
}
}
use of javax.swing.JRadioButtonMenuItem in project knetbuilder by Rothamsted.
the class AppearanceMenuAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent ae) {
String cmd = ae.getActionCommand();
OVTK2Desktop desktop = OVTK2Desktop.getInstance();
OVTK2ResourceAssesor resources = OVTK2Desktop.getDesktopResources();
OVTK2Viewer viewer = (OVTK2Viewer) resources.getSelectedViewer();
// triggers all events to load saved appearance
if (cmd.equals(LOADAPPEARANCE)) {
if (viewer != null) {
AppearanceSynchronizer.loadAppearance(desktop, viewer);
}
} else // toggle node Attribute colour parsing
if (cmd.equals(NODECOLOR)) {
if (viewer != null) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
if (item.isSelected())
AppearanceSynchronizer.loadNodeColor(viewer.getONDEXJUNGGraph(), viewer.getNodeColors(), viewer.getNodeDrawPaint());
else {
viewer.getNodeColors().setFillPaintSelection(NodeFillPaintSelection.CONCEPTCLASS);
viewer.getNodeColors().updateAll();
viewer.getNodeDrawPaint().setDrawPaintSelection(NodeDrawPaintSelection.NONE);
viewer.getNodeDrawPaint().updateAll();
}
// notify model of change
viewer.getVisualizationViewer().getModel().fireStateChanged();
}
} else // toggle node shape Attribute parsing
if (cmd.equals(NODESHAPE)) {
if (viewer != null) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
if (item.isSelected())
AppearanceSynchronizer.loadNodeShape(viewer.getONDEXJUNGGraph(), viewer.getNodeShapes());
else {
viewer.getNodeShapes().setNodeShapeSelection(NodeShapeSelection.NONE);
viewer.getNodeShapes().setNodeSizes(new Transformer<ONDEXConcept, Integer>() {
@Override
public Integer transform(ONDEXConcept input) {
return Config.defaultNodeSize;
}
});
viewer.getNodeShapes().setNodeAspectRatios(new Transformer<ONDEXConcept, Float>() {
@Override
public Float transform(ONDEXConcept input) {
return 1.0f;
}
});
viewer.getNodeShapes().updateAll();
}
// notify model of change
viewer.getVisualizationViewer().getModel().fireStateChanged();
}
} else // toggle edge Attribute colour parsing
if (cmd.equals(EDGECOLOR)) {
if (viewer != null) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
if (item.isSelected())
AppearanceSynchronizer.loadEdgeColor(viewer.getONDEXJUNGGraph(), viewer.getEdgeColors());
else {
viewer.getEdgeColors().setEdgeColorSelection(EdgeColorSelection.RELATIONTYPE);
viewer.getEdgeColors().updateAll();
}
// notify model of change
viewer.getVisualizationViewer().getModel().fireStateChanged();
}
} else // toggle edge size Attribute parsing
if (cmd.equals(EDGESIZE)) {
if (viewer != null) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
if (item.isSelected())
AppearanceSynchronizer.loadEdgeSize(viewer.getONDEXJUNGGraph(), viewer.getEdgeStrokes());
else
viewer.getEdgeStrokes().setEdgeSizes(null);
// notify model of change
viewer.getVisualizationViewer().getModel().fireStateChanged();
}
} else // toggle mouse over for current viewer
if (cmd.equals(SHOWMOUSEOVER)) {
if (viewer != null) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
OVTK2GraphMouse mouse = (OVTK2GraphMouse) viewer.getVisualizationViewer().getGraphMouse();
OVTK2PickingMousePlugin picking = mouse.getOVTK2PickingMousePlugin();
if (picking != null)
picking.setShowMouseOver(item.isSelected());
}
} else // sync node positions to Attribute
if (cmd.equals(SAVEAPPEARANCE)) {
if (viewer != null) {
AppearanceSynchronizer.saveAppearance(viewer);
}
} else // toggle edge arrows
if (cmd.equals("edgearrow")) {
if (viewer != null) {
boolean selected = ((JCheckBoxMenuItem) ae.getSource()).isSelected();
viewer.getEdgeArrows().setShowArrow(selected);
// notify model of change
viewer.getVisualizationViewer().getModel().fireStateChanged();
}
} else // toggle node label visibility
if (cmd.equals("nodelabels")) {
if (viewer != null) {
boolean selected = ((JCheckBoxMenuItem) ae.getSource()).isSelected();
viewer.setShowNodeLabels(selected);
}
} else // toggle edge label visibility
if (cmd.equals("edgelabels")) {
if (viewer != null) {
boolean selected = ((JCheckBoxMenuItem) ae.getSource()).isSelected();
viewer.setShowEdgeLabels(selected);
}
} else // toggle both label visibility
if (cmd.equals("bothlabels")) {
if (viewer != null) {
boolean selected = ((JCheckBoxMenuItem) ae.getSource()).isSelected();
viewer.setShowNodeLabels(selected);
viewer.setShowEdgeLabels(selected);
}
} else // centre graph
if (cmd.equals("center")) {
if (viewer != null) {
viewer.center();
}
} else // toggle anti-aliased painting
if (cmd.equals("antialiased")) {
if (viewer != null) {
boolean selected = ((JCheckBoxMenuItem) ae.getSource()).isSelected();
viewer.setAntiAliased(selected);
}
} else // updates all graphical graph settings
if (cmd.equals("update")) {
if (viewer != null) {
viewer.updateViewer(null);
}
} else // change colour selection strategy
if (cmd.startsWith("Menu.Appearance.Default.")) {
if (viewer != null) {
boolean selected = ((JRadioButtonMenuItem) ae.getSource()).isSelected();
if (selected) {
if (cmd.equals(COLOR_CONCEPT_BY_SOURCE))
viewer.getNodeColors().setFillPaintSelection(ONDEXNodeFillPaint.NodeFillPaintSelection.DATASOURCE);
else if (cmd.equals(COLOR_CONCEPT_BY_CLASS))
viewer.getNodeColors().setFillPaintSelection(ONDEXNodeFillPaint.NodeFillPaintSelection.CONCEPTCLASS);
else if (cmd.equals(COLOR_CONCEPT_BY_EVIDENCE))
viewer.getNodeColors().setFillPaintSelection(ONDEXNodeFillPaint.NodeFillPaintSelection.EVIDENCETYPE);
else if (cmd.equals(COLOR_RELATION_BY_TYPE))
viewer.getEdgeColors().setEdgeColorSelection(ONDEXEdgeColors.EdgeColorSelection.RELATIONTYPE);
else if (cmd.equals(COLOR_RELATION_BY_EVIDECE))
viewer.getEdgeColors().setEdgeColorSelection(ONDEXEdgeColors.EdgeColorSelection.EVIDENCETYPE);
else if (cmd.equals(SHAPE_QUAD))
viewer.getEdgeShapes().setEdgeShape(EdgeShape.QUAD);
else if (cmd.equals(SHAPE_CUBIC))
viewer.getEdgeShapes().setEdgeShape(EdgeShape.CUBIC);
else if (cmd.equals(SHAPE_BENT))
viewer.getEdgeShapes().setEdgeShape(EdgeShape.BENT);
else if (cmd.equals(SHAPE_LINE))
viewer.getEdgeShapes().setEdgeShape(EdgeShape.LINE);
else
System.err.println("Command is not understood " + cmd);
viewer.updateViewer(null);
}
}
}
}
use of javax.swing.JRadioButtonMenuItem in project josm by JOSM.
the class SourceButton method generatePopupMenu.
protected void generatePopupMenu() {
JPopupMenu pm = new JPopupMenu();
this.sourceButtonGroup = new ButtonGroup();
for (TileSource ts : this.sources) {
JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(ts.getName());
TileSourceButtonModel buttonModel = new TileSourceButtonModel(ts);
menuItem.setModel(buttonModel);
pm.add(menuItem);
this.sourceButtonGroup.add(menuItem);
// attempt to initialize button group matching current state of slippyMapBBoxChooser
buttonModel.setSelected(this.slippyMapBBoxChooser.getTileController().getTileSource().getId().equals(ts.getId()));
}
pm.addSeparator();
JCheckBoxMenuItem showDownloadAreaItem = new JCheckBoxMenuItem(tr("Show downloaded area"));
showDownloadAreaItem.setModel(this.showDownloadAreaButtonModel);
pm.add(showDownloadAreaItem);
this.setPopupMenu(pm);
}
Aggregations