Example usage for java.awt.event ItemEvent getStateChange

List of usage examples for java.awt.event ItemEvent getStateChange

Introduction

In this page you can find the example usage for java.awt.event ItemEvent getStateChange.

Prototype

public int getStateChange() 

Source Link

Document

Returns the type of state change (selected or deselected).

Usage

From source file:op.care.prescription.DlgRegular.java

private void rbActiveItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        txtTo.setText("");
    }/*  w  w  w . ja  v  a 2  s. c  o m*/
}

From source file:op.care.prescription.DlgRegular.java

private void rbEndOfPackageItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        txtTo.setText("");
    }//from  w  ww  . j a v a  2  s .  co  m
}

From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private JPanel createQuerySelectionPanel() {
    JPanel querySelectionPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    querySelectionPanel.setLayout(gbl);/*from www .ja v  a2s  . co m*/

    //The selectQueryCombo
    selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(selectQueryLabel, c);
    querySelectionPanel.add(selectQueryLabel);

    //TODO: SwingBoost: localize this:
    selectQueryCombo = new JComboBox(new String[] { "loading queries..." });
    selectQueryCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            RegistryBrowser.setWaitCursor();
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String item = (String) ev.getItem();
            int index = ((JComboBox) ev.getSource()).getSelectedIndex();

            QueryType uiQueryType = queries.get(index);

            try {
                setQuery(uiQueryType);
            } catch (JAXRException e) {
                RegistryBrowser.setDefaultCursor();
                throw new UndeclaredThrowableException(e);
            }
            RegistryBrowser.setDefaultCursor();
        }
    });

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(selectQueryCombo, c);
    querySelectionPanel.add(selectQueryCombo);

    //The nameTextField
    queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryNameLabel, c);
    querySelectionPanel.add(queryNameLabel);

    queryNameText = new JTextField();
    queryNameText.setEditable(false);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryNameText, c);
    querySelectionPanel.add(queryNameText);

    //The description TextArea
    queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryDescLabel, c);
    querySelectionPanel.add(queryDescLabel);

    queryDescText = new JTextArea(4, 25);
    queryDescText.setLineWrap(true);
    queryDescText.setEditable(false);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryDescText, c);
    querySelectionPanel.add(queryDescText);

    return querySelectionPanel;
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JPanel getExecusedIds(final ModelGraph graph) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBorder(new EtchedBorder());
    panel.add(new JLabel("ExcusedSubProcessorIds:"), BorderLayout.NORTH);
    JPanel checkBoxes = new JPanel();
    checkBoxes.setLayout(new GridLayout(graph.getChildren().size(), 1));
    if (graph.hasChildren()) {
        for (ModelGraph childGraph : graph.getChildren()) {
            final String modelId = childGraph.getModel().getModelId();
            Checkbox checkbox = new Checkbox(modelId,
                    graph.getModel().getExcusedSubProcessorIds().contains(modelId));
            checkBoxes.add(checkbox);//from w ww. ja v a 2s. c  om
            checkbox.addItemListener(new ItemListener() {

                public void itemStateChanged(ItemEvent e) {
                    if (e.getStateChange() == ItemEvent.DESELECTED) {
                        graph.getModel().getExcusedSubProcessorIds().remove(modelId);
                    } else if (e.getStateChange() == ItemEvent.SELECTED) {
                        graph.getModel().getExcusedSubProcessorIds().add(modelId);
                    } else {
                        return;
                    }
                    DefaultPropView.this.notifyListeners();
                }

            });
        }
    }
    panel.add(checkBoxes, BorderLayout.CENTER);
    return panel;
}

From source file:op.care.prescription.DlgRegular.java

private void rbDateItemStateChanged(ItemEvent e) {
    txtTo.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
    if (e.getStateChange() == ItemEvent.SELECTED) {
        txtTo.setText(DateFormat.getDateInstance().format(new Date()));
    }/*from   ww  w .  j a v  a  2 s  . c o m*/
}

From source file:net.pms.encoders.TsMuxeRVideo.java

@Override
public JComponent config() {
    // Apply the orientation for the locale
    Locale locale = new Locale(configuration.getLanguage());
    ComponentOrientation orientation = ComponentOrientation.getOrientation(locale);
    String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, ROW_SPEC);

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);/*from  w  w  w .  j  a va2  s.  co m*/

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("TSMuxerVideo.3"),
            FormLayoutUtil.flip(cc.xyw(2, 1, 1), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    tsmuxerforcefps = new JCheckBox(Messages.getString("TSMuxerVideo.2"));
    tsmuxerforcefps.setContentAreaFilled(false);
    if (configuration.isTsmuxerForceFps()) {
        tsmuxerforcefps.setSelected(true);
    }
    tsmuxerforcefps.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setTsmuxerForceFps(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(tsmuxerforcefps, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));

    muxallaudiotracks = new JCheckBox(Messages.getString("TSMuxerVideo.19"));
    muxallaudiotracks.setContentAreaFilled(false);
    if (configuration.isMuxAllAudioTracks()) {
        muxallaudiotracks.setSelected(true);
    }

    muxallaudiotracks.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMuxAllAudioTracks(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(muxallaudiotracks, FormLayoutUtil.flip(cc.xy(2, 5), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java

/**
 * Initializes the components./*from w  w  w . j  a  va 2s .c om*/
 * 
 * @param imageName   The name of the image.
 * @param type      The type of projection.
 * @param maxZ      The maximum number of z-sections.
 * @param startZ   The lower bound of the z-section interval.
 * @param endZ      The upper bound of the z-section interval.
 */
private void initComponents(String imageName, String type, int maxZ, int startZ, int endZ) {
    parentsBox = new JComboBox();

    parentsBoxListener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                DataNode node = (DataNode) parentsBox.getSelectedItem();
                if (!node.isDefaultNode() && !node.getDataObject().canLink()) {
                    selectedContainer = null;
                    parentsBox.setSelectedIndex(0);
                }
                populateDatasetsBox(null);
            }
        }
    };
    parentsBox.removeItemListener(parentsBoxListener);
    datasetsBox = new JComboBox();
    datasetsBoxListener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                DataNode node = (DataNode) datasetsBox.getSelectedItem();
                if (node != null) {
                    if (!node.isDefaultNode() && !node.getDataObject().canLink()) {
                        //Determine the first dataset that be picked.
                        datasetsBox.setSelectedIndex(0);
                        node = (DataNode) datasetsBox.getSelectedItem();
                        selectedDataset = (DatasetData) node.getDataObject();
                    } else
                        selectedDataset = (DatasetData) node.getDataObject();
                }
            }

        }
    };
    datasetsBox.removeItemListener(datasetsBoxListener);
    rndSettingsBox = new JCheckBox("Apply same rendering settings");
    rndSettingsBox.setToolTipText(
            UIUtilities.formatToolTipText("Apply the rendering settings to " + "the projected image."));
    rndSettingsBox.setSelected(true);

    zrangeSelection = new TextualTwoKnobsSlider(1, maxZ, startZ, endZ);
    zrangeSelection.layoutComponents(TextualTwoKnobsSlider.LAYOUT_FIELDS);

    timeSelection = new TextualTwoKnobsSlider(1, maxT, 1, maxT);
    timeSelection.layoutComponents(TextualTwoKnobsSlider.LAYOUT_FIELDS);
    timeSelection.setEnabled(maxT > 1);

    Map<String, String> map = EditorUtil.PIXELS_TYPE_DESCRIPTION;
    String[] data = new String[map.size()];
    Set set = map.entrySet();
    Entry entry;
    Iterator i = set.iterator();
    int index = 0;
    //String originalType = type;
    String key;
    int selectedIndex = 0;
    while (i.hasNext()) {
        entry = (Entry) i.next();
        key = (String) entry.getKey();
        data[index] = (String) entry.getValue();
        if (key.equals(type))
            selectedIndex = index;
        index++;
    }
    pixelsType = new JComboBox(data);
    pixelsType.setSelectedIndex(selectedIndex);
    pixelsType.setEnabled(algorithm == ProjectionParam.SUM_INTENSITY);

    selectionPane = new JPanel();
    selectionPane.setLayout(new BoxLayout(selectionPane, BoxLayout.Y_AXIS));

    closeButton = new JButton("Cancel");
    closeButton.setToolTipText(UIUtilities.formatToolTipText("Close the window."));
    closeButton.setActionCommand("" + CLOSE);
    closeButton.addActionListener(this);
    projectButton = new JButton("Save");
    projectButton.setToolTipText(UIUtilities.formatToolTipText("Project the image."));
    projectButton.setActionCommand("" + PROJECT);
    projectButton.addActionListener(this);
    newFolderButton = new JButton("New Dataset...");
    newFolderButton.setToolTipText(UIUtilities.formatToolTipText("Create a new Dataset."));
    newFolderButton.setActionCommand("" + NEWFOLDER);
    newFolderButton.addActionListener(this);
    nameField = new JTextField();

    StringBuffer buffer = new StringBuffer();
    buffer.append(UIUtilities.removeFileExtension(imageName));
    buffer.append(DEFAULT_EXTENSION);
    nameField.setText(buffer.toString());
    nameField.getDocument().addDocumentListener(this);
    //Display datasets
    getRootPane().setDefaultButton(projectButton);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();
        }
    });
}

From source file:com.openbravo.pos.panels.JTicketsFinder.java

private void jcboUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboUserItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        jButton3ActionPerformed(null);/*  w  w  w .jav a2s.  c o  m*/
    }
}

From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java

private void cbEnvironmentItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnvironmentItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        String env = cbEnvironment.getSelectedItem().toString();
        UserProperties.setLastEnv(env);/*w  w w  . j a  va 2  s.c o  m*/
        UserProperties.save();
    }
}

From source file:op.controlling.PnlQMSSchedule.java

private void cmbTagItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        if (cmbTag.getSelectedIndex() == 0) {
            spinDayInMonth.setModel(new SpinnerNumberModel(1, 1, 31, 1));
        } else {//from  w  w  w .  j ava 2  s . c o m
            spinDayInMonth.setModel(new SpinnerNumberModel(1, 1, 5, 1));
        }
    }
}