Search in sources :

Example 1 with JRadioButtonMenuItem

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);
}
Also used : ButtonGroup(javax.swing.ButtonGroup) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem)

Example 2 with JRadioButtonMenuItem

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();
}
Also used : ActionListener(java.awt.event.ActionListener) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) ActionEvent(java.awt.event.ActionEvent)

Example 3 with JRadioButtonMenuItem

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");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 4 with JRadioButtonMenuItem

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);
}
Also used : ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) DriverProxy(org.apache.felix.upnp.tester.discovery.DriverProxy) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) BundleException(org.osgi.framework.BundleException)

Example 5 with JRadioButtonMenuItem

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);
    }
}
Also used : JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Component(java.awt.Component) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)109 ButtonGroup (javax.swing.ButtonGroup)57 JMenu (javax.swing.JMenu)57 ActionEvent (java.awt.event.ActionEvent)55 ActionListener (java.awt.event.ActionListener)48 JMenuItem (javax.swing.JMenuItem)44 ItemEvent (java.awt.event.ItemEvent)24 ItemListener (java.awt.event.ItemListener)24 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)19 JPopupMenu (javax.swing.JPopupMenu)14 JPanel (javax.swing.JPanel)13 BorderLayout (java.awt.BorderLayout)12 JLabel (javax.swing.JLabel)12 JTextField (javax.swing.JTextField)12 JOptionPane (javax.swing.JOptionPane)10 MenuEvent (javax.swing.event.MenuEvent)10 MenuListener (javax.swing.event.MenuListener)10 JRadioButton (javax.swing.JRadioButton)9 HousePart (org.concord.energy3d.model.HousePart)9 AbstractAction (javax.swing.AbstractAction)8