Example usage for java.awt.event ItemEvent SELECTED

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

Introduction

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

Prototype

int SELECTED

To view the source code for java.awt.event ItemEvent SELECTED.

Click Source Link

Document

This state-change value indicates that an item was selected.

Usage

From source file:Main.java

public void itemStateChanged(ItemEvent ie) {
    JCheckBox cb = (JCheckBox) ie.getItem();

    if (ie.getStateChange() == ItemEvent.SELECTED)
        System.out.println(cb.getText() + " selected.");
    else//from  ww w  .ja  va 2 s  . c o m
        System.out.println(cb.getText() + " cleared.");

    if (jcbOption1.isSelected())
        System.out.println("1");
    else if (jcbOption2.isSelected())
        System.out.println("2");
    else if (jcbOption3.isSelected())
        System.out.println("3");
    else
        System.out.println("None");
}

From source file:Composite.java

public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() != ItemEvent.SELECTED) {
        return;//  w  w  w. j a  va  2 s  .  c o  m
    }

    Object choice = e.getSource();
    if (choice == alphas) {
        alpha = (String) alphas.getSelectedItem();
    } else {
        rule = rules.getSelectedIndex();
    }
    comp.changeRule(alpha, rule);
}

From source file:mulavito.gui.control.CountingPickedState.java

@Override
public boolean pick(T v, boolean b) {
    boolean prior_state = picked.contains(v);
    if (b) {//from  w  w  w.ja  v a2  s .c  o  m
        if (prior_state == false)
            fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, v, ItemEvent.SELECTED));

        picked.add(v);
    } else {
        if (prior_state == true) {
            picked.remove(v, 1);

            if (!picked.contains(v))
                fireItemStateChanged(
                        new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, v, ItemEvent.DESELECTED));
        }
    }
    return prior_state;
}

From source file:com.emr.schemas.ForeignDataMover.java

/**
 * Form for moving foreign data/*www .  j a  v  a  2 s. co m*/
 * @param emrConn Connection to the emr database
 * @param mpiConn Connection to the mpi database
 * @param sourceColumn The column that has the foreign key
 */
public ForeignDataMover(final Connection emrConn, final Connection mpiConn, String sourceColumn) {
    this.emrConn = emrConn;
    this.mpiConn = mpiConn;
    this.sourceColumn = sourceColumn;
    sourceTables = getDatabaseTables(emrConn);
    sourceTablesModel = new DefaultComboBoxModel(sourceTables.toArray(new String[sourceTables.size()]));

    destTables = getDatabaseTables(mpiConn);
    destTablesModel = new DefaultComboBoxModel(destTables.toArray(new String[destTables.size()]));

    initComponents();
    txtSelectedCollumn.setText("<html><b color='green'>" + sourceColumn + "</b></html>");
    cmbForeignTables.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                String selectedTable = (String) e.getItem();
                //populate primary table columns
                List primaryColumns = getTableColumns(selectedTable, emrConn);
                sourcePrimaryFields = new DefaultComboBoxModel(
                        primaryColumns.toArray(new String[primaryColumns.size()]));
                cmbPrimaryKey.setModel(sourcePrimaryFields);
                sourceUniqueFields = new DefaultComboBoxModel(
                        primaryColumns.toArray(new String[primaryColumns.size()]));
                cmbUniquekey.setModel(sourceUniqueFields);
            }
        }
    });
    cmbMPITables.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                String selectedTable = (String) e.getItem();
                //populate primary table columns
                List columns = getTableColumns(selectedTable, mpiConn);
                mpiPrimarycolumns = new DefaultComboBoxModel(columns.toArray(new String[columns.size()]));
                cmbMPIPrimaryKey.setModel(mpiPrimarycolumns);
                mpiUniquFields = new DefaultComboBoxModel(columns.toArray(new String[columns.size()]));
                cmbMPIUniqueField.setModel(mpiUniquFields);
            }
        }
    });
}

From source file:MainClass.java

public void itemStateChanged(ItemEvent itemEvent) {
    int state = itemEvent.getStateChange();
    if (state == ItemEvent.SELECTED) {
        int position = findColorLabel(itemEvent.getItem());
        if ((position != -1) && (position != labels.length - 1)) {
            ColorSelectionModel selectionModel = getColorSelectionModel();
            selectionModel.setSelectedColor(colors[position]);
        }//w  w w.  ja v  a  2  s .c  om
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingRadio.java

public SwingRadio(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("radio");
    radioButton = new JRadioButton();
    setManagedObject(radioButton);//from  w ww .ja  va 2 s . co  m

    // wrong type of event to listen to.. this one fires even on mouse over. use itemlistener
    // radioButton.addChangeListener(new ChangeListener(){
    // public void stateChanged(ChangeEvent evt){
    // logger.debug("firing selected property change: isSelected="+SwingRadio.this.isSelected());
    // SwingRadio.this.changeSupport.firePropertyChange("selected", null, SwingRadio.this.isSelected());
    // }
    // });

    radioButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
            logger.debug("firing selected property change: isSelected=" + selected);
            SwingRadio.this.changeSupport.firePropertyChange("selected", null, selected);
        }

    });
}

From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.support.FileSelectionComponent.java

private void createComponent(Predicate projectFilter) {
    projectsCombobox = new JComboBox(projectList(projectFilter));
    new ComboBoxAutoCompletion(projectsCombobox);
    model = new DefaultListModel();
    list = new JList(model);
    list.setPreferredSize(new Dimension(150, 150));
    projectsCombobox.addItemListener(new ItemListener() {
        @Override/*w  w  w .j  a va2s . c o m*/
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateList(e.getItem());
            }
        }
    });

    setLayout(new BorderLayout());
    add(projectsCombobox, BorderLayout.NORTH);
    add(new JScrollPane(list), BorderLayout.CENTER);
}

From source file:org.pentaho.ui.xul.swing.tags.SwingMenuList.java

public SwingMenuList(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("menulist");

    this.xulDomContainer = domContainer;

    combobox = new JComboBox(new DefaultComboBoxModel());
    setManagedObject(combobox);/*from www .j av  a  2 s . c  o  m*/

    combobox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED && !inLayoutProcess && initialized) {
                fireSelectedEvents();
            }
        }

    });

}

From source file:org.cagrid.installer.steps.PresentLicenseStep.java

public void init(WizardModel m) {
    this.model = (CaGridInstallerModel) m;

    setLayout(new BorderLayout());
    setSize(new Dimension(475, 161));

    JPanel licensePanel = new JPanel();
    licensePanel.setBackground(Color.WHITE);
    JTextPane textPane = new JTextPane();
    licensePanel.add(textPane);//w  w  w.  j a va2  s  .co  m
    JScrollPane scrollPane = new JScrollPane(licensePanel);
    scrollPane.setPreferredSize(new Dimension(475, 150));
    add(scrollPane, BorderLayout.CENTER);

    try {
        StringBuilder sb = new StringBuilder();
        BufferedReader r = new BufferedReader(
                new InputStreamReader(getClass().getResourceAsStream("/cagrid_license.txt")));
        String line = null;
        while ((line = r.readLine()) != null) {
            sb.append(line).append("\n");
        }
        textPane.setText(sb.toString());
        textPane.setFont(textPane.getFont().deriveFont((float) 10));
    } catch (Exception ex) {
        String msg = "Error loading license: " + ex.getMessage();
        logger.error(msg, ex);
        JOptionPane.showMessageDialog(null, msg, this.model.getMessage("error"), JOptionPane.ERROR_MESSAGE);
    }

    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new GridBagLayout());
    add(controlPanel, BorderLayout.SOUTH);

    JLabel label = new JLabel(this.model.getMessage("accept.license"));
    controlPanel.add(label);

    JCheckBox checkBox = new JCheckBox();
    checkBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent evt) {
            PresentLicenseStep.this.setComplete(evt.getStateChange() == ItemEvent.SELECTED);
        }
    });
    controlPanel.add(checkBox);
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRInitialController.java

/**
 * Initialize view.//from  www .ja v a 2 s.com
 */
@Override
protected void initDRInitialPanel() {
    dRInitialPlotPanel = new DRInitialPlotPanel();

    //init chart panel
    initialChartPanel = new ChartPanel(null);
    initialChartPanel.setOpaque(false);
    /**
     * Action listeners for buttons
     */

    /**
     * If selected, text field to enter value for parameter constraining
     * will be taken into account on plotting.
     */
    dRInitialPlotPanel.getBottomCheckBox().addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                bottomConstrainValue = 0.0;
            } else {
                bottomConstrainValue = null;
            }
        }
    });

    dRInitialPlotPanel.getTopCheckBox().addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                topConstrainValue = 0.0;
            } else {
                topConstrainValue = null;
            }
        }
    });

    /**
     * Perform fitting and plot new dose-response graph, taking into account
     * any choices made by the user.
     */
    dRInitialPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (bottomConstrainValue != null) {
                bottomConstrainValue = Double.parseDouble(dRInitialPlotPanel.getBottomTextField().getText());
            }
            if (topConstrainValue != null) {
                topConstrainValue = Double.parseDouble(dRInitialPlotPanel.getTopTextField().getText());
            }
            doseResponseController
                    .performFitting(
                            dataToFit, doseResponseController.getdRAnalysisGroup()
                                    .getDoseResponseAnalysisResults().getFittingResults(false),
                            bottomConstrainValue, topConstrainValue);
            //Plot fitted data in dose-response curve, along with R annotation
            doseResponseController.plotDoseResponse(initialChartPanel,
                    dRInitialPlotPanel.getDoseResponseChartParentPanel(), dataToFit,
                    doseResponseController.getdRAnalysisGroup(), false);
            //Calculate new statistics
            doseResponseController.calculateStatistics();
        }
    });
}