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:gdt.jgui.tool.JTextEncrypter.java

/**
 * The default constructor./*from www.  j av  a2s  .  co  m*/
 */
public JTextEncrypter() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel panel = new JPanel();
    panel.setBorder(
            new TitledBorder(null, "Master password", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel);
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    JCheckBox chckbxNewCheckBox = new JCheckBox("Show");
    chckbxNewCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    chckbxNewCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() != ItemEvent.SELECTED) {
                passwordField.setEchoChar('*');
            } else {
                passwordField.setEchoChar((char) 0);
            }
        }
    });
    panel.add(chckbxNewCheckBox);
    panel.setFocusTraversalPolicy(
            new FocusTraversalOnArray(new Component[] { chckbxNewCheckBox, passwordField }));
    passwordField = new JPasswordField();
    passwordField.setMaximumSize(new Dimension(Integer.MAX_VALUE, passwordField.getPreferredSize().height));
    panel.add(passwordField);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(null, "Text", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    textArea = new JTextArea();
    textArea.setColumns(1);
    panel_1.add(textArea);

}

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

/**
 * Form for moving foreign data//from   w w  w . j  av a2 s . c  o 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:op.care.med.structure.DlgTradeForm.java

private void cbWeightControlledItemStateChanged(ItemEvent e) {
    tradeForm.setWeightControlled(e.getStateChange() == ItemEvent.SELECTED);
}

From source file:TextBouncer.java

protected Checkbox createCheckbox(String label, final int item) {
    Checkbox check = new Checkbox(label);
    check.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            setSwitch(item, (ie.getStateChange() == ie.SELECTED));
        }/*from  w  w w  .  j a v  a2  s.  co  m*/
    });
    return check;
}

From source file:de.jakop.ngcalsync.application.TrayStarter.java

private ItemListener createSchedulerItemListener(final Settings settings, final Application application) {

    return new ItemListener() {

        @Override// w  w  w.j a  va  2s  .  c o m
        public void itemStateChanged(final ItemEvent e) {
            try {
                final boolean started = e.getStateChange() == ItemEvent.SELECTED;
                toggleScheduler(started, settings, application);
                settings.setSchedulerStarted(started);
                settings.save();
            } catch (final ConfigurationException ex) {
                throw new RuntimeException(ex);
            }
        }
    };
}

From source file:eu.europeana.sip.gui.SipCreatorGUI.java

private JPanel createConnectPanel() {
    connectedBox = new JCheckBox(String.format(CONNECT_TO, sipModel.getAppConfigModel().getServerHostPort()));
    sipModel.getAppConfigModel().addListener(new AppConfigModel.Listener() {
        @Override/*from  www .  j ava2s  . co m*/
        public void appConfigUpdated(AppConfig appConfig) {
            connectedBox.setText(String.format(CONNECT_TO, sipModel.getAppConfigModel().getServerHostPort()));
        }
    });
    connectedBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            boolean enabled = itemEvent.getStateChange() == ItemEvent.SELECTED;
            dataSetClient.setListFetchingEnabled(enabled);
            if (!enabled) {
                dataSetListModel.clear();
                for (FileStore.DataSetStore dataSetStore : sipModel.getFileStore().getDataSetStores()
                        .values()) {
                    dataSetListModel.setDataSetStore(dataSetStore);
                }
            }
            titleLabel.setText(enabled ? LOCAL_AND_REMOTE_SETS : LOCAL_SETS);
        }
    });
    JPanel p = new JPanel(new FlowLayout());
    p.add(connectedBox);
    return p;
}

From source file:org.smart.migrate.ui.RelationDialog.java

private void cbxFKTableItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxFKTableItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        initFields(cbxFK, (String) evt.getItem());
        if (StringUtils.isNotBlank(tableRelation.getForeignKey())) {
            cbxFK.setSelectedItem(tableRelation.getForeignKey());
        }//from   ww w . j  a  v a  2  s  . c o  m
    }
}

From source file:org.smart.migrate.ui.RelationDialog.java

private void cbxPKTableItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxPKTableItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        initFields(cbxPK, (String) evt.getItem());
        if (StringUtils.isNotBlank(tableRelation.getPrimaryKey())) {
            cbxPK.setSelectedItem(tableRelation.getPrimaryKey());
        }//from ww w . j  a v  a2s  .com
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.BarChartGenerator.java

protected void buildGlobalAttributes(LabelledList list) {
    // create the chart
    CategoryPlot plot = (CategoryPlot) (chart.getPlot());
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinePaint(new Color(200, 200, 200));
    plot.setRangeGridlinePaint(new Color(200, 200, 200));

    // define the renderers
    barRenderer = new BarRenderer();
    reviseRenderer(barRenderer);/*from   ww  w  . ja va2  s .  co  m*/

    stackedBarRenderer = new StackedBarRenderer(false);
    reviseRenderer(stackedBarRenderer);

    percentageRenderer = new StackedBarRenderer(true);
    reviseRenderer(percentageRenderer);

    plot.setRenderer(barRenderer);

    xLabel = new PropertyField() {
        public String newValue(String newValue) {
            setXAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    xLabel.setValue(getXAxisLabel());

    list.add(new JLabel("X Label"), xLabel);

    yLabel = new PropertyField() {
        public String newValue(String newValue) {
            setYAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    yLabel.setValue(getYAxisLabel());

    list.add(new JLabel("Y Label"), yLabel);

    final JCheckBox gridlines = new JCheckBox();
    gridlines.setSelected(false);
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hasgridlines = (e.getStateChange() == ItemEvent.SELECTED);
            updateGridLines();
        }
    };
    gridlines.addItemListener(il);

    list.add(new JLabel("Grid Lines"), gridlines);

    final JCheckBox labels = new JCheckBox();
    labels.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                getBarRenderer().setBaseItemLabelsVisible(true);
                getStackedBarRenderer().setBaseItemLabelsVisible(true);
                getPercentageRenderer().setBaseItemLabelsVisible(true);
            } else {
                getBarRenderer().setBaseItemLabelsVisible(false);
                getStackedBarRenderer().setBaseItemLabelsVisible(false);
                getPercentageRenderer().setBaseItemLabelsVisible(false);
            }
        }
    };
    labels.addItemListener(il);
    list.add(new JLabel("Labels"), labels);

    final JComboBox barType = new JComboBox();
    barType.setEditable(false);
    barType.setModel(new DefaultComboBoxModel(
            new java.util.Vector(Arrays.asList(new String[] { "Separate", "Stacked", "Percentage" }))));
    barType.setSelectedIndex(0);
    barType.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            int type = barType.getSelectedIndex();

            if (type == 0) // separate
            {
                plot.setRenderer(getBarRenderer());
            } else if (type == 1) // stacked
            {
                plot.setRenderer(getStackedBarRenderer());
            } else // percentage
            {
                plot.setRenderer(getPercentageRenderer());
            }
        }
    });
    list.add(new JLabel("Bars"), barType);

    final JCheckBox horizontal = new JCheckBox();
    horizontal.setSelected(false);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            if (e.getStateChange() == ItemEvent.SELECTED) {
                plot.setOrientation(PlotOrientation.HORIZONTAL);
                ishorizontal = true;
            } else {
                plot.setOrientation(PlotOrientation.VERTICAL);
                ishorizontal = false;
            }
            updateGridLines();
        }
    };
    horizontal.addItemListener(il);

    list.add(new JLabel("Horizontal"), horizontal);
}

From source file:op.care.med.structure.DlgTradeForm.java

private void cmbDaysWeeksItemStateChanged(ItemEvent e) {
    if (initPhase)
        return;/*from   w  ww  . j a v a 2s.  co m*/
    if (e.getStateChange() == ItemEvent.SELECTED) {
        Integer i = SYSTools.checkInteger(txtExpiresIn.getText());
        if (i == null || i.compareTo(0) <= 0) {
            i = 7;
            txtExpiresIn.setText("7");
        }
        if (cmbDaysWeeks.getSelectedIndex() == 1) {
            tradeForm.setDaysToExpireAfterOpened(i * 7);
        } else {
            tradeForm.setDaysToExpireAfterOpened(i);
        }
    }
}