Search in sources :

Example 16 with JRadioButton

use of javax.swing.JRadioButton in project adempiere by adempiere.

the class VProductConfigurationBOM method actionPerformed.

//	getPreferredSize
/**************************************************************************
	 *	Action Listener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    log.config(e.getActionCommand());
    Object source = e.getSource();
    //	Toggle Qty Enabled
    if (source instanceof JCheckBox || source instanceof JRadioButton) {
        cmd_selection(source);
        //	need to de-select the others in group	
        if (source instanceof JRadioButton) {
            //	find Button Group
            Iterator it = m_buttonGroups.values().iterator();
            while (it.hasNext()) {
                ButtonGroup group = (ButtonGroup) it.next();
                Enumeration en = group.getElements();
                while (en.hasMoreElements()) {
                    //	We found the group
                    if (source == en.nextElement()) {
                        Enumeration info = group.getElements();
                        while (info.hasMoreElements()) {
                            Object infoObj = info.nextElement();
                            if (source != infoObj)
                                cmd_selection(infoObj);
                        }
                    }
                }
            }
        }
    } else //	Product / Qty
    if (source == productField || source == productQty) {
        m_qty = (BigDecimal) productQty.getValue();
        KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
        m_product = MProduct.get(Env.getCtx(), pp.getKey());
        createMainPanel();
        sizeIt();
    } else //	Order
    if (source == orderField) {
        KeyNamePair pp = (KeyNamePair) orderField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Invoice
    if (source == invoiceField) {
        KeyNamePair pp = (KeyNamePair) invoiceField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Project
    if (source == projectField) {
        KeyNamePair pp = (KeyNamePair) projectField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
    } else //	OK
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
        if (cmd_save())
            dispose();
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
        dispose();
    //	Enable OK
    boolean OK = m_product != null;
    if (OK) {
        KeyNamePair pp = null;
        if (orderField != null)
            pp = (KeyNamePair) orderField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && invoiceField != null)
            pp = (KeyNamePair) invoiceField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && projectField != null)
            pp = (KeyNamePair) projectField.getSelectedItem();
        OK = (pp != null && pp.getKey() > 0);
    }
    confirmPanel.getOKButton().setEnabled(OK);
}
Also used : JCheckBox(javax.swing.JCheckBox) JRadioButton(javax.swing.JRadioButton) Enumeration(java.util.Enumeration) ButtonGroup(javax.swing.ButtonGroup) Iterator(java.util.Iterator) org.eevolution.form.bom.nodeUserObject(org.eevolution.form.bom.nodeUserObject) KeyNamePair(org.compiere.util.KeyNamePair) BigDecimal(java.math.BigDecimal)

Example 17 with JRadioButton

use of javax.swing.JRadioButton in project aerospike-client-java by aerospike.

the class GuiDisplay method initialize.

/**
	 * Initialize the contents of the frame.
	 */
private void initialize() {
    frmAerospikeExamples = new JFrame();
    frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
    frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmAerospikeExamples.pack();
    frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
    mainPanel = new JPanel();
    splitPane.setLeftComponent(mainPanel);
    mainPanel.setLayout(new BorderLayout(0, 0));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    runButton = new JButton("Run");
    runButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            consoleTextArea.setText("");
            run_selected_examples();
        }
    });
    buttonPanel.add(runButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    exitButton = new JButton("Quit");
    exitButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            Container Frame = exitButton.getParent();
            do {
                Frame = Frame.getParent();
            } while (!(Frame instanceof JFrame));
            ((JFrame) Frame).dispose();
        }
    });
    buttonPanel.add(exitButton);
    sourceTextPane = new JTextArea();
    sourceTextPane.setTabSize(2);
    sourceTextPane.setEditable(false);
    scrollPane = new JScrollPane(sourceTextPane);
    scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    scrollPane.setPreferredSize(new Dimension(600, 100));
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    connectionPanel = new JPanel();
    connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    lblServerHost = new JLabel("Server Host");
    connectionPanel.add(lblServerHost);
    seedHostTextField = new JTextField();
    seedHostTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.host = seedHostTextField.getText();
        }
    });
    connectionPanel.add(seedHostTextField);
    seedHostTextField.setColumns(10);
    lblPort = new JLabel("Port");
    connectionPanel.add(lblPort);
    portTextField = new JTextField();
    portTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent arg0) {
            String newValue = namespaceTextField.getText();
            if (newValue != null && newValue != "") {
                try {
                    params.port = Integer.parseInt(newValue);
                } catch (NumberFormatException ne) {
                //ne.printStackTrace();
                }
            }
        }
    });
    connectionPanel.add(portTextField);
    portTextField.setColumns(4);
    lblusername = new JLabel("User");
    connectionPanel.add(lblusername);
    usernameTextField = new JTextField();
    usernameTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = usernameTextField.getText();
        }
    });
    connectionPanel.add(usernameTextField);
    usernameTextField.setColumns(8);
    lblpassword = new JLabel("Password");
    connectionPanel.add(lblpassword);
    passwordTextField = new JPasswordField();
    passwordTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = new String(passwordTextField.getPassword());
        }
    });
    connectionPanel.add(passwordTextField);
    passwordTextField.setColumns(8);
    lblnameSpace = new JLabel("Namespace");
    connectionPanel.add(lblnameSpace);
    namespaceTextField = new JTextField();
    namespaceTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.namespace = namespaceTextField.getText();
        }
    });
    connectionPanel.add(namespaceTextField);
    namespaceTextField.setColumns(8);
    lblSet = new JLabel("Set");
    connectionPanel.add(lblSet);
    txtSetTextfield = new JTextField();
    txtSetTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.set = txtSetTextfield.getText();
        }
    });
    connectionPanel.add(txtSetTextfield);
    txtSetTextfield.setColumns(8);
    mainPanel.add(connectionPanel, BorderLayout.NORTH);
    examplePanel = new JPanel();
    examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
    exampleScrollPane = new JScrollPane(examplePanel);
    mainPanel.add(exampleScrollPane, BorderLayout.WEST);
    // init values
    seedHostTextField.setText(params.host);
    portTextField.setText(Integer.toString(params.port));
    namespaceTextField.setText(params.namespace);
    txtSetTextfield.setText(params.set);
    //int width = 785;
    int width = 1000;
    int height = 180;
    consoleTextArea = new JTextArea();
    consoleTextArea.setSize(new Dimension(width, height));
    consoleTextArea.setEditable(false);
    consoleScrollPane = new JScrollPane(consoleTextArea);
    consoleScrollPane.setPreferredSize(new Dimension(width, height));
    consoleScrollPane.setSize(new Dimension(width, height));
    splitPane.setRightComponent(consoleScrollPane);
    buttonGroup = new ButtonGroup();
    JRadioButton jrb;
    for (String example : Main.getAllExampleNames()) {
        jrb = new JRadioButton(example);
        jrb.setActionCommand(example);
        jrb.addActionListener(this);
        buttonGroup.add(jrb);
        examplePanel.add(jrb);
    }
    frmAerospikeExamples.pack();
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) KeyAdapter(java.awt.event.KeyAdapter) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) KeyEvent(java.awt.event.KeyEvent) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EtchedBorder(javax.swing.border.EtchedBorder) JPasswordField(javax.swing.JPasswordField) ButtonGroup(javax.swing.ButtonGroup) JSplitPane(javax.swing.JSplitPane)

Example 18 with JRadioButton

use of javax.swing.JRadioButton in project jmeter by apache.

the class FtpConfigGui method createOptionsPanel.

private JPanel createOptionsPanel() {
    ButtonGroup group = new ButtonGroup();
    //$NON-NLS-1$
    getBox = new JRadioButton(JMeterUtils.getResString("ftp_get"));
    group.add(getBox);
    getBox.setSelected(true);
    //$NON-NLS-1$
    putBox = new JRadioButton(JMeterUtils.getResString("ftp_put"));
    group.add(putBox);
    //$NON-NLS-1$
    binaryMode = new JCheckBox(JMeterUtils.getResString("ftp_binary_mode"));
    //$NON-NLS-1$
    saveResponseData = new JCheckBox(JMeterUtils.getResString("ftp_save_response_data"));
    JPanel optionsPanel = new HorizontalPanel();
    optionsPanel.add(getBox);
    optionsPanel.add(putBox);
    optionsPanel.add(binaryMode);
    optionsPanel.add(saveResponseData);
    return optionsPanel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel)

Example 19 with JRadioButton

use of javax.swing.JRadioButton in project jmeter by apache.

the class SizeAssertionGui method createFieldPanel.

/**
     * Create a panel allowing the user to choose which response field should be
     * tested.
     *
     * @return a new panel for selecting the response field
     */
private JPanel createFieldPanel() {
    JPanel panel = new JPanel();
    //$NON-NLS-1$
    panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_resp_size_field")));
    //$NON-NLS-1$
    responseNetworkButton = new JRadioButton(JMeterUtils.getResString("assertion_network_size"));
    //$NON-NLS-1$
    responseHeadersButton = new JRadioButton(JMeterUtils.getResString("assertion_headers"));
    //$NON-NLS-1$
    responseBodyButton = new JRadioButton(JMeterUtils.getResString("assertion_body_resp"));
    //$NON-NLS-1$
    responseCodeButton = new JRadioButton(JMeterUtils.getResString("assertion_code_resp"));
    //$NON-NLS-1$
    responseMessageButton = new JRadioButton(JMeterUtils.getResString("assertion_message_resp"));
    ButtonGroup group = new ButtonGroup();
    group.add(responseNetworkButton);
    group.add(responseHeadersButton);
    group.add(responseBodyButton);
    group.add(responseCodeButton);
    group.add(responseMessageButton);
    panel.add(responseNetworkButton);
    panel.add(responseHeadersButton);
    panel.add(responseBodyButton);
    panel.add(responseCodeButton);
    panel.add(responseMessageButton);
    responseNetworkButton.setSelected(true);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup)

Example 20 with JRadioButton

use of javax.swing.JRadioButton in project jmeter by apache.

the class SizeAssertionGui method createComparatorButton.

private JRadioButton createComparatorButton(String name, int value, ButtonGroup group) {
    JRadioButton button = new JRadioButton(name);
    button.setActionCommand(String.valueOf(value));
    button.addActionListener(this);
    group.add(button);
    return button;
}
Also used : JRadioButton(javax.swing.JRadioButton)

Aggregations

JRadioButton (javax.swing.JRadioButton)117 ButtonGroup (javax.swing.ButtonGroup)76 JPanel (javax.swing.JPanel)55 JLabel (javax.swing.JLabel)54 JButton (javax.swing.JButton)32 BoxLayout (javax.swing.BoxLayout)30 ActionEvent (java.awt.event.ActionEvent)29 JCheckBox (javax.swing.JCheckBox)29 ActionListener (java.awt.event.ActionListener)25 JTextField (javax.swing.JTextField)25 JScrollPane (javax.swing.JScrollPane)24 FlowLayout (java.awt.FlowLayout)17 GridBagLayout (java.awt.GridBagLayout)17 BorderLayout (java.awt.BorderLayout)16 GridBagConstraints (java.awt.GridBagConstraints)15 Insets (java.awt.Insets)11 JSpinner (javax.swing.JSpinner)11 JTable (javax.swing.JTable)11 Dimension (java.awt.Dimension)9 JComboBox (javax.swing.JComboBox)9