Search in sources :

Example 31 with JCheckBox

use of javax.swing.JCheckBox in project qi4j-sdk by Qi4j.

the class Main method main.

public static void main(String[] args) throws Exception {
    SingletonAssembler assembler = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(BoundPersonComposite.class);
            module.transients(AddressTransient.class);
            module.values(CityValue.class, CountryValue.class);
            new SwingBindingAssembler().assemble(module);
        }
    };
    module = assembler.module();
    Address address1 = createAddress("Vista Damai", "Jalan Tun Razak");
    Address address2 = createAddress("Mutiara", "Jalan Ceylon");
    TransientBuilder<BoundPersonComposite> builder = module.newTransientBuilder(BoundPersonComposite.class);
    PersonComposite prototype = builder.prototype();
    prototype.address().set(address1);
    prototype.firstName().set("Niclas");
    final BoundPersonComposite p1 = builder.newInstance();
    prototype.address().set(address2);
    prototype.firstName().set("Edward");
    final BoundPersonComposite p2 = builder.newInstance();
    final StateModel<BoundPersonComposite> model = module.newObject(StateModel.class, BoundPersonComposite.class);
    Form form = new Form<BoundPersonComposite>(model);
    JFrame frame = new JFrame("testing");
    frame.add(form, BorderLayout.CENTER);
    JPanel checkBoxPanel = new JPanel();
    checkBoxPanel.setFocusable(true);
    checkBoxPanel.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            System.out.println("Gained!");
        }

        public void focusLost(FocusEvent e) {
            System.out.println("LOst!");
        }
    });
    JCheckBox sw = new JCheckBox("Toggle");
    sw.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (((JCheckBox) e.getSource()).isSelected()) {
                model.use(p1);
                System.out.println(p1.firstName().get());
            } else {
                model.use(p2);
                System.out.println(p2.firstName().get());
            }
        }
    });
    checkBoxPanel.add(sw);
    frame.add(checkBoxPanel, BorderLayout.EAST);
    frame.pack();
    System.out.println(model);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
Also used : JPanel(javax.swing.JPanel) SwingBindingAssembler(org.qi4j.lib.swing.binding.SwingBindingAssembler) ActionEvent(java.awt.event.ActionEvent) FocusEvent(java.awt.event.FocusEvent) JCheckBox(javax.swing.JCheckBox) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) FocusListener(java.awt.event.FocusListener)

Example 32 with JCheckBox

use of javax.swing.JCheckBox in project pcgen by PCGen.

the class PCGenFrame method maybeShowWarningConfirm.

@Override
public Boolean maybeShowWarningConfirm(String title, String message, String checkBoxText, final PropertyContext context, final String contextProp) {
    if (!context.getBoolean(contextProp, true)) {
        return null;
    }
    final JCheckBox checkBox = new JCheckBox(checkBoxText, true);
    checkBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            context.setBoolean(contextProp, checkBox.isSelected());
        }
    });
    JPanel panel = buildMessageLabelPanel(message, checkBox);
    int ret = JOptionPane.showConfirmDialog(this, panel, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
    return ret == JOptionPane.YES_OPTION;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener)

Example 33 with JCheckBox

use of javax.swing.JCheckBox in project zaproxy by zaproxy.

the class OptionsScannerPanel method getChkHandleAntiCSRFTokens.

private JCheckBox getChkHandleAntiCSRFTokens() {
    if (chkHandleAntiCrsfTokens == null) {
        chkHandleAntiCrsfTokens = new JCheckBox();
        chkHandleAntiCrsfTokens.setText(Constant.messages.getString("ascan.options.anticsrf.label"));
    }
    return chkHandleAntiCrsfTokens;
}
Also used : JCheckBox(javax.swing.JCheckBox)

Example 34 with JCheckBox

use of javax.swing.JCheckBox in project zaproxy by zaproxy.

the class OptionsScannerPanel method getChkInjectPluginIdInHeader.

private JCheckBox getChkInjectPluginIdInHeader() {
    if (chkInjectPluginIdInHeader == null) {
        chkInjectPluginIdInHeader = new JCheckBox();
        chkInjectPluginIdInHeader.setText(Constant.messages.getString("ascan.options.pluginHeader.label"));
    }
    return chkInjectPluginIdInHeader;
}
Also used : JCheckBox(javax.swing.JCheckBox)

Example 35 with JCheckBox

use of javax.swing.JCheckBox in project zaproxy by zaproxy.

the class OptionsScannerPanel method getChkPromptInAttackMode.

private JCheckBox getChkPromptInAttackMode() {
    if (chkPromptInAttackMode == null) {
        chkPromptInAttackMode = new JCheckBox(Constant.messages.getString("ascan.options.attackPrompt.label"));
        chkPromptInAttackMode.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                getChkRescanInAttackMode().setEnabled(!chkPromptInAttackMode.isSelected());
            }
        });
    }
    return chkPromptInAttackMode;
}
Also used : JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Aggregations

JCheckBox (javax.swing.JCheckBox)491 JPanel (javax.swing.JPanel)199 JLabel (javax.swing.JLabel)155 JButton (javax.swing.JButton)108 ActionEvent (java.awt.event.ActionEvent)98 ActionListener (java.awt.event.ActionListener)93 JTextField (javax.swing.JTextField)88 GridBagConstraints (java.awt.GridBagConstraints)82 GridBagLayout (java.awt.GridBagLayout)77 Insets (java.awt.Insets)66 BorderLayout (java.awt.BorderLayout)63 Dimension (java.awt.Dimension)59 BoxLayout (javax.swing.BoxLayout)56 JScrollPane (javax.swing.JScrollPane)38 ItemEvent (java.awt.event.ItemEvent)37 ItemListener (java.awt.event.ItemListener)34 FlowLayout (java.awt.FlowLayout)33 JComboBox (javax.swing.JComboBox)33 JRadioButton (javax.swing.JRadioButton)32 Box (javax.swing.Box)30