use of javax.swing.JRadioButtonMenuItem in project voltdb by VoltDB.
the class DatabaseManagerSwing method updateSchemaList.
private void updateSchemaList() {
ButtonGroup group = new ButtonGroup();
ArrayList list = new ArrayList();
ResultSet result = null;
try {
result = dMeta.getSchemas();
if (result == null) {
throw new SQLException("Failed to get metadata from database");
}
while (result.next()) {
list.add(result.getString(1));
}
} catch (SQLException se) {
CommonSwing.errorMessage(se);
} finally {
if (result != null) {
try {
result.close();
} catch (SQLException se) {
}
}
}
mnuSchemas.removeAll();
rbAllSchemas.setSelected(schemaFilter == null);
group.add(rbAllSchemas);
mnuSchemas.add(rbAllSchemas);
String s;
JRadioButtonMenuItem radioButton;
for (int i = 0; i < list.size(); i++) {
s = (String) list.get(i);
radioButton = new JRadioButtonMenuItem(s);
group.add(radioButton);
mnuSchemas.add(radioButton);
radioButton.setSelected(schemaFilter != null && schemaFilter.equals(s));
radioButton.addActionListener(schemaListListener);
radioButton.setEnabled(list.size() > 1);
}
mnuSchemas.addSeparator();
mnuSchemas.add(mitemUpdateSchemas);
}
use of javax.swing.JRadioButtonMenuItem in project ACS by ACS-Community.
the class ObjectExplorer method startConnect.
/**
* Insert the method's description here.
* Creation date: (9.4.2002 17:47:22)
* @param param javax.swing.JRadioButtonMenuItem
*/
private void startConnect(String name) {
java.awt.Component[] c = getConnectMenu().getMenuComponents();
boolean sel = false;
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof JRadioButtonMenuItem) {
((JRadioButtonMenuItem) c[i]).setSelected(((JRadioButtonMenuItem) c[i]).getName().equals(name));
sel = sel || ((JRadioButtonMenuItem) c[i]).isSelected();
}
}
if (!sel) {
JRadioButtonMenuItem radio = new JRadioButtonMenuItem();
radio.setActionCommand(name);
radio.setName(name);
radio.setText(name);
radio.setSelected(true);
radio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent a) {
startConnect(((JRadioButtonMenuItem) a.getSource()).getName());
}
});
getConnectMenu().insert(radio, getConnectMenu().getMenuComponentCount() - 2);
}
//TODO: finish this
getTreeHandlerBean1().setAccess(name);
getOETree1().clearTree();
//getOETreeByName().clearTree();
}
use of javax.swing.JRadioButtonMenuItem in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
use of javax.swing.JRadioButtonMenuItem in project felix by apache.
the class ControlPoint method doMenuBar.
public void doMenuBar(JFrame frame) {
JMenuBar menuBar = new JMenuBar();
// ////////////// FILE
JMenu file_menu = new JMenu("File");
file_menu.setMnemonic(KeyEvent.VK_F);
searchMenu = new JMenu("Search");
final String ALL_DEVICE = "ssdp:all";
final String ROOT_DEVICE = "upnp:rootdevice";
searchMenu.setMnemonic(KeyEvent.VK_L);
searchMenu.setEnabled(false);
AbstractAction searchAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ALL_DEVICE))
controller.doSearch(ALL_DEVICE);
else if (e.getActionCommand().equals(ROOT_DEVICE))
controller.doSearch(ROOT_DEVICE);
}
};
JMenuItem rootDeviceItem = new JMenuItem("Root Devices");
rootDeviceItem.setMnemonic(KeyEvent.VK_R);
rootDeviceItem.addActionListener(searchAction);
rootDeviceItem.setActionCommand(ROOT_DEVICE);
searchMenu.add(rootDeviceItem);
JMenuItem allDeviceItem = new JMenuItem("All Devices");
allDeviceItem.setMnemonic(KeyEvent.VK_A);
allDeviceItem.addActionListener(searchAction);
allDeviceItem.setActionCommand(ALL_DEVICE);
searchMenu.add(allDeviceItem);
JMenuItem checkIncompleteItem = new JMenuItem("Print Pending Devices");
checkIncompleteItem.setMnemonic(KeyEvent.VK_I);
checkIncompleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.getRootDeviceListener().checkIncompleteDevice();
}
});
JMenuItem checkErrataItem = new JMenuItem("Check Errata UPnPDevices");
checkErrataItem.setMnemonic(KeyEvent.VK_E);
checkErrataItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
RootDeviceListener.checkErrataDevice();
}
});
loggerMenu = new JMenu("Felix Logger");
final String NO_LOGGING = "No Logging";
final String ERROR = "Error";
final String WARNING = "Warning";
final String INFO = "Info";
final String DEBUG = "Debug";
loggerMenu.getPopupMenu().addPopupMenuListener(this);
loggerMenu.setMnemonic(KeyEvent.VK_L);
loggerMenu.setEnabled(false);
AbstractAction loggerAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(NO_LOGGING))
controller.setLogLevel(0);
else if (e.getActionCommand().equals(ERROR))
controller.setLogLevel(1);
else if (e.getActionCommand().equals(WARNING))
controller.setLogLevel(2);
else if (e.getActionCommand().equals(INFO))
controller.setLogLevel(3);
else if (e.getActionCommand().equals(DEBUG))
controller.setLogLevel(4);
}
};
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem(NO_LOGGING);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_N);
rbMenuItem.setActionCommand(NO_LOGGING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
loggerMenu.addSeparator();
rbMenuItem = new JRadioButtonMenuItem(ERROR);
rbMenuItem.setMnemonic(KeyEvent.VK_E);
rbMenuItem.setActionCommand(ERROR);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(WARNING);
rbMenuItem.setMnemonic(KeyEvent.VK_W);
rbMenuItem.setActionCommand(WARNING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(INFO);
rbMenuItem.setMnemonic(KeyEvent.VK_I);
rbMenuItem.setActionCommand(INFO);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(DEBUG);
rbMenuItem.setMnemonic(KeyEvent.VK_D);
rbMenuItem.setActionCommand(DEBUG);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
final String ON = "On";
final String OFF = "Off";
cyberMenu = new JMenu("Cyber Debugger");
cyberMenu.getPopupMenu().addPopupMenuListener(this);
cyberMenu.setMnemonic(KeyEvent.VK_C);
cyberMenu.setEnabled(false);
AbstractAction cyberAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ON))
controller.setCyberDebug(true);
else if (e.getActionCommand().equals(OFF))
controller.setCyberDebug(false);
}
};
ButtonGroup cyberGroup = new ButtonGroup();
rbMenuItem = new JRadioButtonMenuItem(ON);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_O);
rbMenuItem.setActionCommand(ON);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(OFF);
rbMenuItem.setMnemonic(KeyEvent.VK_F);
rbMenuItem.setActionCommand(OFF);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
/*
JMenuItem clearSubscriptionItem = new JMenuItem("Clear Subscriptions");
clearSubscriptionItem.setMnemonic(KeyEvent.VK_S);
clearSubscriptionItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// to do
}
});
*/
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(KeyEvent.VK_X);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Activator.context.getBundle().stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
file_menu.add(searchMenu);
file_menu.addSeparator();
file_menu.add(loggerMenu);
file_menu.add(cyberMenu);
file_menu.addSeparator();
file_menu.add(checkIncompleteItem);
file_menu.add(checkErrataItem);
// file_menu.addSeparator();
// file_menu.add(clearSubscriptionItem);
file_menu.addSeparator();
file_menu.add(exitItem);
menuBar.add(file_menu);
frame.setJMenuBar(menuBar);
}
use of javax.swing.JRadioButtonMenuItem in project felix by apache.
the class ControlPoint method popupMenuWillBecomeVisible.
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
JPopupMenu loggerPopup = loggerMenu.getPopupMenu();
JPopupMenu cyberPopup = cyberMenu.getPopupMenu();
if (e.getSource() == loggerPopup) {
int logLevel = Mediator.getDriverProxy().getLogLevel();
Component[] items = loggerPopup.getComponents();
((JRadioButtonMenuItem) items[logLevel > 0 ? logLevel + 1 : 0]).setSelected(true);
} else if (e.getSource() == cyberPopup) {
boolean cyberDebug = Mediator.getDriverProxy().getCyberDebug();
Component[] items = cyberPopup.getComponents();
if (cyberDebug)
((JRadioButtonMenuItem) items[0]).setSelected(true);
else
((JRadioButtonMenuItem) items[1]).setSelected(true);
}
}
Aggregations