Search in sources :

Example 96 with ActionListener

use of java.awt.event.ActionListener 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 97 with ActionListener

use of java.awt.event.ActionListener in project SKMCLauncher by SKCraft.

the class VersionListDialog method initComponents.

private void initComponents() {
    JPanel mainPanel = new JPanel();
    versionsList = new JList();
    JScrollPane versionsScroll = new JScrollPane(versionsList);
    LinedBoxPanel buttonsPanel = new LinedBoxPanel(true).fullyPadded();
    JButton cancelButton = new JButton(_("button.cancel"));
    JButton selectButton = new JButton(_("button.select"));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(versionsScroll, BorderLayout.CENTER);
    buttonsPanel.addGlue();
    buttonsPanel.addElement(selectButton);
    buttonsPanel.addElement(cancelButton);
    add(mainPanel, BorderLayout.CENTER);
    add(buttonsPanel, BorderLayout.SOUTH);
    cancelButton.addActionListener(ActionListeners.dispose(this));
    selectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Object selected = versionsList.getSelectedValue();
            if (selected != null && selected instanceof Version) {
                version = (Version) selected;
            }
            dispose();
        }
    });
    getRootPane().setDefaultButton(selectButton);
    versionsList.addMouseListener(new DoubleClickToButtonAdapter(selectButton));
    ListenableFuture<?> future = executor.submit(new AbstractWorker<Object>() {

        @Override
        protected void run() throws Exception {
            try {
                setVersions(application.getAvailable());
            } catch (IOException e) {
                dispose();
                throw new LauncherException(e, _("versionList.failedFetchError"));
            } catch (InterruptedException e) {
                dispose();
            }
        }

        @Override
        public String getLocalizedTitle() {
            return _("selectVersions.fetchingVersionsTitle");
        }

        @Override
        public boolean shouldConfirmInterrupt() {
            return false;
        }
    });
    SwingHelper.addErrorDialogCallback(future, this);
}
Also used : LauncherException(com.sk89q.skmcl.LauncherException) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) IOException(java.io.IOException) LauncherException(com.sk89q.skmcl.LauncherException) ActionListener(java.awt.event.ActionListener) Version(com.sk89q.skmcl.application.Version)

Example 98 with ActionListener

use of java.awt.event.ActionListener in project SKMCLauncher by SKCraft.

the class ConsoleFrame method initComponents.

/**
     * Add components to the frame.
     */
private void initComponents() {
    JButton pastebinButton = new JButton(_("console.uploadLog"));
    buttonsPanel = new LinedBoxPanel(true);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    buttonsPanel.addElement(pastebinButton);
    add(buttonsPanel, BorderLayout.NORTH);
    add(messageLog, BorderLayout.CENTER);
    pastebinButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pastebinLog();
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 99 with ActionListener

use of java.awt.event.ActionListener in project SKMCLauncher by SKCraft.

the class LoginDialog method bindListeners.

private void bindListeners() {
    idCombo.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    passwordText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    idCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateSelection();
        }
    });
    forgotLogin.addActionListener(ActionListeners.openURL(forgotLogin, "https://minecraft.net/resetpassword"));
    loginButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            prepareLogin();
        }
    });
    cancelButton.addActionListener(ActionListeners.dispose(this));
    rememberPassCheck.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rememberPassCheck.isSelected()) {
                rememberIdCheck.setSelected(true);
            }
        }
    });
    rememberIdCheck.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!rememberIdCheck.isSelected()) {
                rememberPassCheck.setSelected(false);
            }
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 100 with ActionListener

use of java.awt.event.ActionListener in project folding-plugin by dmytrodanylyk.

the class SettingConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    useCustomPatternCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            boolean selected = getCheckBoxStatus(actionEvent);
            customPattern.setEnabled(selected);
            isModified = true;
        }
    });
    customPattern.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            isModified = true;
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            isModified = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            isModified = true;
        }
    });
    hideFoldingPrefix.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            isModified = true;
        }
    });
    reset();
    return mPanel;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ActionListener (java.awt.event.ActionListener)1347 ActionEvent (java.awt.event.ActionEvent)1303 JButton (javax.swing.JButton)363 JPanel (javax.swing.JPanel)345 JLabel (javax.swing.JLabel)234 JMenuItem (javax.swing.JMenuItem)191 BoxLayout (javax.swing.BoxLayout)150 GridBagConstraints (java.awt.GridBagConstraints)121 Insets (java.awt.Insets)121 GridBagLayout (java.awt.GridBagLayout)114 Dimension (java.awt.Dimension)113 FlowLayout (java.awt.FlowLayout)110 JCheckBox (javax.swing.JCheckBox)103 JScrollPane (javax.swing.JScrollPane)103 JMenu (javax.swing.JMenu)96 BorderLayout (java.awt.BorderLayout)88 JTextField (javax.swing.JTextField)79 JComboBox (javax.swing.JComboBox)73 ButtonGroup (javax.swing.ButtonGroup)64 ArrayList (java.util.ArrayList)60