Example usage for java.awt.event ItemEvent getSource

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

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);/*w  w  w .jav a2s . c  om*/

    //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:dictionary.GUI.GUI_Main.java

private void button1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_button1ItemStateChanged
    if (evt.getSource() == button1) {
        voice.setVoice("mbrola_us1");
    }//from  ww  w  .  j  a v a2s  .c o  m
    if (evt.getSource() == button2) {
        voice.setVoice("mbrola_us2");
    }
}

From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java

public void itemStateChanged(ItemEvent e) {
    if (e.getSource() == profEinschrBox) {
        if (profEinschrBox != null && profEinschrBox.isSelected() == false && profileField != null) {
            profileField.setEnabled(false);
            profileField.setEditable(false);
            profDateiBox.setEnabled(false);
        } else {/*w ww. java 2 s .  c  o  m*/
            profileField.setEnabled(true);
            profileField.setEditable(true);
            profDateiBox.setEnabled(true);
        }
    }
    if (e.getSource() == pkgBox) {
        if (pkgBox != null && pkgBox.isSelected() == false && pkgField != null) {
            pkgField.setEnabled(false);
            pkgField.setEditable(false);
        } else {
            pkgField.setEnabled(true);
            pkgField.setEditable(true);
        }
    }
}

From source file:zsk.JFCMainClient.java

public void itemStateChanged(ItemEvent e) {
    if (e.getSource() == this.saveconfigcheckbox)
        if (e.getStateChange() == java.awt.event.ItemEvent.SELECTED)
            debugoutput("saving config on exit.");
        else/*from  ww w  .  j ava 2  s.c  om*/
            debugoutput("don't saving config on exit.");

    if (e.getSource() == this.save3dcheckbox)
        if (e.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            debugoutput("trying: 3D");
            output("trying: 3D");
        } else {
            debugoutput("trying: normal 2D");
            output("trying: normal 2D");
        }

}

From source file:game.Clue.ClueGameUI.java

public void itemStateChanged(ItemEvent evt) {
    System.out.println(evt.getSource().toString());
    CardLayout cl = (CardLayout) (jPanel3.getLayout());
    cl.next(jPanel3);/*from  ww  w .ja  v  a2s. c o  m*/
    //show(jPanel3, (String)evt.getItem());
    System.out.println("itemStateChanged");
}

From source file:shuffle.fwk.service.teams.EditTeamService.java

private Component createTeamComponent(Species s) {
    Team curTeam = getCurrentTeam();/*from w ww .  j ava 2s  .co m*/
    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 2;
    Indicator<SpeciesPaint> ind = new Indicator<SpeciesPaint>(this);
    boolean isMega = megaProgress >= megaThreshold && s.getName().equals(curTeam.getMegaSlotName());
    SpeciesPaint paint = new SpeciesPaint(s, s.equals(Species.FREEZE), isMega);
    ind.setVisualized(paint);
    ret.add(ind, c);
    c.gridy += 1;
    c.gridwidth = 1;
    JButton removeButton = new JButton(getString(KEY_REMOVE));
    removeButton.setToolTipText(getString(KEY_REMOVE_TOOLTIP));
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            removeSpeciesFromTeam(s.getName());
            updateTeamPanel();
        }
    });
    removeButton.setEnabled(
            s.getEffect(getUser().getRosterManager()).isPickable() && !s.getType().equals(PkmType.NONE));
    ret.add(removeButton, c);

    c.gridx += 1;
    JComboBox<Character> keybindsComboBox = new JComboBox<Character>();
    Character curBinding = curTeam.getBinding(s);
    LinkedHashSet<Character> allBindingsFor = new LinkedHashSet<Character>(Arrays.asList(curBinding));
    LinkedHashSet<Character> availableBindings = myData.getAllAvailableBindingsFor(s.getName(), curTeam);
    allBindingsFor.addAll(availableBindings);
    for (Character ch : allBindingsFor) {
        keybindsComboBox.addItem(ch);
    }
    keybindsComboBox.setSelectedItem(curBinding);
    final ItemListener bindingListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JComboBox<?> source = (JComboBox<?>) e.getSource();
            int selectedIndex = source.getSelectedIndex();
            Character selected = (Character) source.getItemAt(selectedIndex);
            setBinding(s, selected);
            updateKeybindComboBoxes();
        }
    };
    nameToKeybindComboboxMap.put(s.getName(), keybindsComboBox);
    nameToItemListenerMap.put(s.getName(), bindingListener);
    keybindsComboBox.addItemListener(bindingListener);
    keybindsComboBox.setToolTipText(getString(KEY_KEYBINDS_TOOLTIP));
    ret.add(keybindsComboBox, c);

    MouseAdapter ma = new PressToggleMouseAdapter() {

        @Override
        protected void onRight(MouseEvent e) {
            doToggle();
        }

        @Override
        protected void onLeft(MouseEvent e) {
            doToggle();
        }

        private void doToggle() {
            toggleSupport(s);
            updateTeamPanel();
        }
    };
    ret.addMouseListener(ma);

    setBorderFor(ret, false, false);
    if (!Species.FIXED_SPECIES.contains(s)) {
        boolean isSupport = !curTeam.isNonSupport(s);
        Color indColor = isSupport ? Color.GREEN : Color.RED;
        ret.setBackground(indColor);
        ret.setOpaque(true);
    }
    return ret;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.LocationDialog.java

/**
 * Listener for Group and Project JComboBox selection events
 * @see ItemChangeListener/*from  w  w  w. j a va 2s .co m*/
 */
public void itemStateChanged(ItemEvent ie) {
    Object source = ie.getSource();
    if (ie.getStateChange() == ItemEvent.SELECTED) {
        if (source == groupsBox) {
            storeCurrentSelections();
            switchToSelectedGroup();
        } else if (source == usersBox) {
            switchToSelectedUser();
        } else if (source == projectsBox) {
            DataNode node = getSelectedItem(projectsBox);
            datasetsBox.setEnabled(true);
            newDatasetButton.setEnabled(true);
            if (node.isDefaultProject())
                newDatasetButton.setEnabled(true);
            populateDatasetsBox();
        }
    }
}

From source file:gdsc.smlm.ij.plugins.PSFCreator.java

public void itemStateChanged(ItemEvent e) {
    // Run the fit configuration plugin to update the settings.
    if (e.getSource() instanceof Checkbox) {
        ((Checkbox) e.getSource()).setState(false);
        IJ.run("Fit Configuration");
    }//from   w w  w.ja v  a 2 s. c o  m
}

From source file:gdsc.smlm.ij.plugins.PeakFit.java

public void itemStateChanged(ItemEvent e) {
    Checkbox cb = (Checkbox) e.getSource();
    if (cb.getState()) {
        cb.setState(false);//from  w  ww.  ja  v  a2s .c  om
        PSFCalculator calculator = new PSFCalculator();
        calculatorSettings.pixelPitch = calibration.nmPerPixel / 1000.0;
        calculatorSettings.magnification = 1;
        calculatorSettings.beamExpander = 1;
        double sd = calculator.calculate(calculatorSettings, true);
        if (sd > 0)
            textInitialPeakStdDev0.setText(Double.toString(sd));
    }
}

From source file:ExText.java

/**
 * Handles on/off checkbox items on a standard menu.
 * /*from   www.jav a  2 s  .c  o m*/
 * @param event
 *            an ItemEvent indicating what requires handling
 */
public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    boolean state;
    if (src == headlightMenuItem) {
        state = headlightMenuItem.getState();
        headlight.setEnable(state);
    } else if (src == walkMenuItem)
        setNavigationType(Walk);
    else if (src == examineMenuItem)
        setNavigationType(Examine);
}