use of javax.swing.JRadioButtonMenuItem in project browsermator by pcalkins.
the class MainAppFrame method initComponents.
@SuppressWarnings("unchecked")
public void initComponents() {
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
editMenu = new javax.swing.JMenu();
undoMenuItem = new javax.swing.JMenuItem();
openMenuItem = new javax.swing.JMenuItem();
saveMenuItem = new javax.swing.JMenuItem();
exitMenuItem = new javax.swing.JMenuItem();
newFileItem = new javax.swing.JMenuItem();
jMenuView = new javax.swing.JMenu();
jMenuThemes = new javax.swing.JMenu();
helpMenu = new javax.swing.JMenu();
contentsMenuItem = new javax.swing.JMenuItem();
aboutMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
browseCloudMenuItem = new javax.swing.JMenuItem();
uploadFileToCloudMenuItem = new javax.swing.JMenuItem();
exitMenuItem = new javax.swing.JMenuItem();
closeMenuItem = new javax.swing.JMenuItem();
importMenuItem = new javax.swing.JMenuItem();
newFileItem.setMnemonic('n');
newFileItem.setText("New");
undoMenuItem.setText("Undo");
openMenuItem.setMnemonic('o');
undoMenuItem.setMnemonic('Z');
openMenuItem.setText("Open");
closeMenuItem.setText("Close");
importMenuItem.setMnemonic('i');
importMenuItem.setText("Import");
editMenu.add(undoMenuItem);
fileMenu.add(newFileItem);
fileMenu.add(openMenuItem);
fileMenu.add(importMenuItem);
fileMenu.setMnemonic('f');
fileMenu.setText("File");
editMenu.setText("Edit");
saveAsMenuItem.setText("Save As");
saveAsMenuItem.setMnemonic('a');
browseCloudMenuItem.setText("BrowserMator File Cloud");
uploadFileToCloudMenuItem.setText("Upload to BrowserMator Cloud");
undoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
closeMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
LAFOptions = UIManager.getInstalledLookAndFeels();
LookAndFeelOptions = new JRadioButtonMenuItem[LAFOptions.length];
LookAndFeelGroup = new ButtonGroup();
for (int count = 0; count < LAFOptions.length; count++) {
LookAndFeelOptions[count] = new JRadioButtonMenuItem(LAFOptions[count].getName());
jMenuThemes.add(LookAndFeelOptions[count]);
LookAndFeelGroup.add(LookAndFeelOptions[count]);
LookAndFeelOptions[count].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
for (int count = 0; count < LAFOptions.length; count++) {
if (LookAndFeelOptions[count].isSelected())
try {
UIManager.setLookAndFeel(LAFOptions[count].getClassName());
SwingUtilities.updateComponentTreeUI(getContentPane());
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
});
}
LookAndFeelOptions[0].setSelected(true);
saveMenuItem.setMnemonic('s');
saveMenuItem.setText("Save");
fileMenu.add(saveMenuItem);
fileMenu.add(closeMenuItem);
exitMenuItem.setMnemonic('x');
exitMenuItem.setText("Exit");
fileMenu.add(exitMenuItem);
saveMenuItem.setMnemonic('s');
saveMenuItem.setText("Save");
fileMenu.add(saveMenuItem);
fileMenu.add(saveAsMenuItem);
fileMenu.add(browseCloudMenuItem);
fileMenu.add(uploadFileToCloudMenuItem);
exitMenuItem.setMnemonic('x');
exitMenuItem.setText("Exit");
fileMenu.add(exitMenuItem);
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
menuBar.add(editMenu);
jMenuThemes.setText("Themes");
jMenuView.setText("View");
menuBar.add(jMenuView);
jMenuView.add(jMenuThemes);
helpMenu.setMnemonic('h');
helpMenu.setText("Help");
contentsMenuItem.setMnemonic('c');
contentsMenuItem.setText("Contents");
helpMenu.add(contentsMenuItem);
aboutMenuItem.setMnemonic('a');
aboutMenuItem.setText("About");
helpMenu.add(aboutMenuItem);
menuBar.add(helpMenu);
setJMenuBar(menuBar);
}
use of javax.swing.JRadioButtonMenuItem in project artisynth_core by artisynth.
the class MenuBarHandler method addRadioMenuItem.
private JRadioButtonMenuItem addRadioMenuItem(JMenu menu, String label, String cmd, ButtonGroup group) {
JRadioButtonMenuItem item = makeRadioMenuItem(label, cmd);
group.add(item);
menu.add(item);
return item;
}
use of javax.swing.JRadioButtonMenuItem in project freeplane by freeplane.
the class MenuRadioActionComponentProvider method createComponent.
/* (non-Javadoc)
* @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
*/
@Override
public Component createComponent(Entry entry) {
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final JMenuItem actionComponent;
IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
if (action.isSelectable()) {
actionComponent = new JAutoRadioButtonMenuItem(wrappedAction);
} else {
actionComponent = new JRadioButtonMenuItem(wrappedAction);
}
actionComponent.setSelected(Boolean.parseBoolean(String.valueOf(entry.getAttribute("selected"))) || entry.getName().equals(getSelectedActionName(entry)));
buttonGroup.add(actionComponent);
final KeyStroke accelerator = accelerators.getAccelerator(action);
actionComponent.setAccelerator(accelerator);
MenuIconScaling.scaleIcon(actionComponent);
return actionComponent;
} else if (entry.builders().contains("separator")) {
return new JPopupMenu.Separator();
} else
return null;
}
use of javax.swing.JRadioButtonMenuItem in project jsql-injection by ron190.
the class SqlEngine method initializeMenuVendor.
private static JPanel initializeMenuVendor() {
var panelCombo = new JPanel();
panelCombo.setLayout(new BorderLayout());
panelCombo.setOpaque(false);
// Disable overlap with zerosizesplitter
panelCombo.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
panelCombo.setPreferredSize(new Dimension(Integer.MAX_VALUE, 25));
panelCombo.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
var menuBarVendor = new JMenuBar();
menuBarVendor.setOpaque(false);
menuBarVendor.setBorder(null);
JMenu comboMenuVendor = new ComboMenu(MediatorHelper.model().getMediatorVendor().getVendor().toString());
menuBarVendor.add(comboMenuVendor);
var groupVendor = new ButtonGroup();
List<Vendor> listVendors = new LinkedList<>(MediatorHelper.model().getMediatorVendor().getVendors());
listVendors.removeIf(vendor -> vendor == MediatorHelper.model().getMediatorVendor().getAuto());
for (final Vendor vendor : listVendors) {
JMenuItem itemRadioVendor = new JRadioButtonMenuItem(vendor.toString(), vendor == MediatorHelper.model().getMediatorVendor().getVendor());
itemRadioVendor.addActionListener(actionEvent -> {
SqlEngine.modelYaml = vendor.instance().getModelYaml();
SqlEngine.initializeTextComponents();
comboMenuVendor.setText(vendor.toString());
});
itemRadioVendor.setUI(new BasicRadioButtonMenuItemUI() {
@Override
protected void doClick(MenuSelectionManager msm) {
this.menuItem.doClick(0);
}
});
comboMenuVendor.add(itemRadioVendor);
groupVendor.add(itemRadioVendor);
}
panelCombo.add(menuBarVendor, BorderLayout.LINE_END);
// Do Overlay
panelCombo.setAlignmentX(FlowLayout.TRAILING);
panelCombo.setAlignmentY(Component.BOTTOM_ALIGNMENT);
return panelCombo;
}
use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class AnnualAnalysis method createOptionsMenu.
JMenu createOptionsMenu(final JDialog dialog, final List<HousePart> selectedParts, final boolean selectAll, final boolean exportStoredResults) {
final JMenuItem miClear = new JMenuItem("Clear Previous Results in Graph");
final JMenuItem miView = new JMenuItem("View Raw Data...");
final JMenuItem miExportStoredResults = new JMenuItem("Export Stored Hourly Results");
final JMenu menu = new JMenu("Options");
menu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(final MenuEvent e) {
miClear.setEnabled(graph.hasRecords());
miView.setEnabled(graph.hasData());
miExportStoredResults.setEnabled(Scene.getInstance().getSolarResults() != null);
}
@Override
public void menuDeselected(final MenuEvent e) {
}
@Override
public void menuCanceled(final MenuEvent e) {
}
});
if (!(this instanceof EnergyAnnualAnalysis)) {
final JMenuItem miFinance = new JMenuItem("Financial Settings...");
miFinance.addActionListener(e -> {
FinancialSettingsDialog fsd = new FinancialSettingsDialog();
switch(Scene.getInstance().getProjectType()) {
case Foundation.TYPE_PV_PROJECT:
fsd.selectPvPrices();
break;
case Foundation.TYPE_CSP_PROJECT:
fsd.selectCspPrices();
break;
}
if (Scene.getInstance().getCalculateRoi() && getResult("Solar") > 0) {
fsd.setRunAfterOK(() -> {
runFinancialAnalysis(dialog);
});
}
fsd.setVisible(true);
});
menu.add(miFinance);
menu.addSeparator();
}
final JMenu chartMenu = new JMenu("Chart");
final ButtonGroup chartGroup = new ButtonGroup();
menu.add(chartMenu);
final JRadioButtonMenuItem miBar = new JRadioButtonMenuItem("Bar");
miBar.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
graph.setGraphType(Graph.BAR_CHART);
graph.repaint();
}
});
chartMenu.add(miBar);
chartGroup.add(miBar);
miBar.setSelected(graph.getGraphType() == Graph.BAR_CHART);
final JRadioButtonMenuItem miLine = new JRadioButtonMenuItem("Line");
miLine.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
graph.setGraphType(Graph.LINE_CHART);
graph.repaint();
}
});
chartMenu.add(miLine);
chartGroup.add(miLine);
miLine.setSelected(graph.getGraphType() == Graph.LINE_CHART);
final JRadioButtonMenuItem miArea = new JRadioButtonMenuItem("Area");
miArea.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
graph.setGraphType(Graph.AREA_CHART);
graph.repaint();
}
});
chartMenu.add(miArea);
chartGroup.add(miArea);
miArea.setSelected(graph.getGraphType() == Graph.AREA_CHART);
miClear.addActionListener(e -> {
final int i = JOptionPane.showConfirmDialog(dialog, "Are you sure that you want to clear all the previous results\nrelated to the selected object?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (i != JOptionPane.YES_OPTION) {
return;
}
graph.clearRecords();
graph.repaint();
TimeSeriesLogger.getInstance().logClearGraphData(graph.getClass().getSimpleName());
});
menu.add(miClear);
miView.addActionListener(e -> {
if (selectedParts == null) {
DataViewer.viewRawData(dialog, graph, selectAll);
} else {
DataViewer.viewRawData(dialog, graph, selectedParts);
}
});
menu.add(miView);
final JMenuItem miCopyImage = new JMenuItem("Copy Image");
miCopyImage.addActionListener(e -> new ClipImage().copyImageToClipboard(graph));
menu.add(miCopyImage);
if (exportStoredResults) {
miExportStoredResults.addActionListener(e -> {
final double[][] solarResults = Scene.getInstance().getSolarResults();
if (solarResults != null) {
double sum = 0;
// Hack to fix the results in case we make a mistake that can be quickly remedied
final double scale = 1;
for (int i = 0; i < solarResults.length; i++) {
for (int j = 0; j < solarResults[i].length; j++) {
solarResults[i][j] *= scale;
sum += solarResults[i][j];
}
}
sum *= 365.0 / 12.0;
StringBuilder s = new StringBuilder();
for (int i = 0; i < solarResults.length; i++) {
s.append("\"").append(AnnualGraph.THREE_LETTER_MONTH[i]).append("\": \"");
for (int j = 0; j < solarResults[i].length; j++) {
s.append(EnergyPanel.FIVE_DECIMALS.format(solarResults[i][j]).replaceAll(",", "")).append(" ");
}
s = new StringBuilder(s.toString().trim() + "\",\n\t");
}
s = new StringBuilder(s.substring(0, s.length() - 1));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(s.toString()), null);
JOptionPane.showMessageDialog(dialog, "A total of " + EnergyPanel.TWO_DECIMALS.format(sum) + " KWh was copied to the clipboard.", "Export", JOptionPane.INFORMATION_MESSAGE);
}
});
menu.add(miExportStoredResults);
}
return menu;
}
Aggregations