Search in sources :

Example 51 with ItemEvent

use of java.awt.event.ItemEvent in project intellij-plugins by JetBrains.

the class RegistrationForm method setupFormActionsAndLF.

private void setupFormActionsAndLF() {
    myUseExisting.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            boolean useExisting = myUseExisting.isSelected();
            JComponent[] hideableFields = new JComponent[] { myNickname, myNicknameLabel, myFirstName, myFirstNameLabel, myLastName, myLastNameLabel, myPasswordAgain, myPasswordAgainLabel };
            for (JComponent hideableField : hideableFields) {
                hideableField.setVisible(!useExisting);
            }
            Window window = SwingUtilities.getWindowAncestor(myPanel);
            if (window != null) {
                window.pack();
            }
        }
    });
    UIUtil.traverse(myPanel, new UIUtil.TraverseAction() {

        public boolean executeAndContinue(Component c) {
            if (c instanceof JTextComponent) {
                JTextComponent textComponent = (JTextComponent) c;
                textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

                    protected void textChanged(DocumentEvent e) {
                        myErrorLabel.setText(null);
                    }
                });
            }
            return true;
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) ItemListener(java.awt.event.ItemListener) JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) UIUtil(jetbrains.communicator.util.UIUtil)

Example 52 with ItemEvent

use of java.awt.event.ItemEvent in project beast-mcmc by beast-dev.

the class HierarchicalPriorDialog method showDialog.

public int showDialog(final java.util.List<Parameter> parameterList) {
    this.parameterList = parameterList;
    this.parameter = parameterList.get(0);
    PriorType priorType = parameter.priorType;
    // Set-up combo box depending on parameters
    priorCombo.removeAllItems();
    if (parameter.isNonNegative) {
        priorCombo.addItem(PriorType.LOGNORMAL_HPM_PRIOR);
    }
    priorCombo.addItem(PriorType.NORMAL_HPM_PRIOR);
    priorCombo.setSelectedItem(priorType);
    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;
    if (parameter.isZeroOne) {
        lower = 0.0;
        upper = 1.0;
    } else if (parameter.isNonNegative) {
        lower = 0.0;
    }
    initialField.setRange(lower, upper);
    initialField.setValue(parameter.getInitial());
    panel = new JPanel(new GridBagLayout());
    setupComponents();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);
    scrollPane.getViewport().setOpaque(false);
    JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, "Phylogenetic Hierarchical Model Setup");
    priorCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            setupComponents();
            dialog.validate();
            dialog.repaint();
            dialog.pack();
        }
    });
    for (PriorOptionsPanel optionsPanel : optionsPanels.values()) {
        optionsPanel.addListener(new PriorOptionsPanel.Listener() {

            public void optionsPanelChanged() {
                setupChart();
                dialog.validate();
                dialog.repaint();
            }
        });
    }
    dialog.pack();
    if (OSType.isMac()) {
        dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        if (d.height < 700 && panel.getHeight() > 450) {
            dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
        } else {
            // setSize because optionsPanel is shrunk in dialog
            dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
        }
    //            System.out.println("panel width = " + panel.getWidth());
    //            System.out.println("panel height = " + panel.getHeight());
    }
    dialog.setResizable(true);
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : ItemEvent(java.awt.event.ItemEvent) PriorType(dr.app.beauti.types.PriorType) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 53 with ItemEvent

use of java.awt.event.ItemEvent in project beast-mcmc by beast-dev.

the class PriorSettingsPanel method setParameter.

/**
     * Set the parameter to be controlled
     *                                                                                                       q
     * @param parameter
     */
public void setParameter(final Parameter parameter) {
    this.parameter = parameter;
    priorCombo = new JComboBox();
    for (PriorType priorType : PriorType.getPriorTypes(parameter)) {
        priorCombo.addItem(priorType);
    }
    if (parameter.priorType != null) {
        priorCombo.setSelectedItem(parameter.priorType);
    }
    // setArguments here
    setupComponents();
    priorCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            setupComponents();
            dialog.pack();
            dialog.repaint();
        }
    });
    for (PriorOptionsPanel optionsPanel : optionsPanels.values()) {
        optionsPanel.removeAllListeners();
        optionsPanel.addListener(new PriorOptionsPanel.Listener() {

            public void optionsPanelChanged() {
                setupChart();
                dialog.pack();
                dialog.repaint();
            }
        });
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener) PriorType(dr.app.beauti.types.PriorType)

Example 54 with ItemEvent

use of java.awt.event.ItemEvent in project processdash by dtuma.

the class DashHierarchy method fireDataFileChange.

// Notify all listeners that have registered interest for
// notification on this event type.  The event instance
// is created using the parameters passed into the fire method.
// For the moment, the only events that will generate these events are:
// setChildKey/move(CHANGE), copyFrom(CREATE), removeChildKey/remove(DELETE)
protected void fireDataFileChange(PendingDataChange item) {
    // Guaranteed to return a non-null array
    Object[] listeners = ell.getListenerList();
    // Process the listeners last to first, notifying
    // those that are interested in this event
    ItemEvent fooEvent = new ItemEvent(this, 0, item, 0);
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ItemListener.class) {
            ((ItemListener) listeners[i + 1]).itemStateChanged(fooEvent);
        }
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) EventObject(java.util.EventObject) ItemListener(java.awt.event.ItemListener)

Example 55 with ItemEvent

use of java.awt.event.ItemEvent in project JMRI by JMRI.

the class GuiLafConfigPane method doClickSelection.

void doClickSelection(JPanel panel) {
    panel.setLayout(new FlowLayout());
    mouseEvent = new JCheckBox(ConfigBundle.getMessage("GUIButtonNonStandardRelease"));
    mouseEvent.setSelected(SwingSettings.getNonStandardMouseEvent());
    mouseEvent.addItemListener((ItemEvent e) -> {
        InstanceManager.getDefault(GuiLafPreferencesManager.class).setNonStandardMouseEvent(mouseEvent.isSelected());
    });
    panel.add(mouseEvent);
}
Also used : JCheckBox(javax.swing.JCheckBox) ItemEvent(java.awt.event.ItemEvent) GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) FlowLayout(java.awt.FlowLayout)

Aggregations

ItemEvent (java.awt.event.ItemEvent)339 ItemListener (java.awt.event.ItemListener)313 ActionEvent (java.awt.event.ActionEvent)120 ActionListener (java.awt.event.ActionListener)110 JPanel (javax.swing.JPanel)106 JLabel (javax.swing.JLabel)84 JCheckBox (javax.swing.JCheckBox)72 JComboBox (javax.swing.JComboBox)65 Dimension (java.awt.Dimension)59 JButton (javax.swing.JButton)53 BorderLayout (java.awt.BorderLayout)48 JTextField (javax.swing.JTextField)46 ButtonGroup (javax.swing.ButtonGroup)35 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)33 GridLayout (java.awt.GridLayout)30 ChangeEvent (javax.swing.event.ChangeEvent)30 GridBagConstraints (java.awt.GridBagConstraints)29 JMenu (javax.swing.JMenu)29 ChangeListener (javax.swing.event.ChangeListener)29 GridBagLayout (java.awt.GridBagLayout)28