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:net.openbyte.gui.CreateProjectFrame.java

private void comboBox1ItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        if (comboBox1.getSelectedIndex() == 1) {
            // mcp
            if (!System.getProperty("os.name").startsWith("Windows")) {
                JOptionPane.showMessageDialog(this,
                        "Python is required for MCP, please make sure you have Python installed.",
                        "Notification", JOptionPane.INFORMATION_MESSAGE);
            }// ww w  .ja va 2  s.c om
            String[] versions = new String[] { "1.9", "1.8.9", "1.7.10" };
            DefaultComboBoxModel mcpModel = new DefaultComboBoxModel(versions);
            comboBox2.setModel(mcpModel);
            return;
        }
        if (comboBox1.getSelectedIndex() == 0) {
            // mcforge
            String[] versions = new String[] { "1.8.9", "1.7.10" };
            DefaultComboBoxModel forgeModel = new DefaultComboBoxModel(versions);
            comboBox2.setModel(forgeModel);
            return;
        }
        if (((String) comboBox1.getSelectedItem()).equals("Bukkit")) {
            // bukkit
            JOptionPane.showMessageDialog(this, "Bukkit is solely ONLY the API, not the implementation!",
                    "Notification", JOptionPane.INFORMATION_MESSAGE);
            String[] versions = new String[] { "1.9" };
            DefaultComboBoxModel bukkitModel = new DefaultComboBoxModel(versions);
            comboBox2.setModel(bukkitModel);
            return;
        }
    }
}

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

private void cbExpiresAfterOpenedItemStateChanged(ItemEvent e) {
    if (initPhase)
        return;//from  w w w  .j  a  v a2s.  c  o m
    txtExpiresIn.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
    cmbDaysWeeks.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
    if (e.getStateChange() == ItemEvent.SELECTED) {
        txtExpiresIn.setText("7");
        cmbDaysWeeks.setSelectedIndex(0);
        tradeForm.setDaysToExpireAfterOpened(7);
    } else {
        tradeForm.setDaysToExpireAfterOpened(null);
    }
}

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

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

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

private void cbxPKTableItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxPKTableItemStateChanged
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        initFields(cbxPKLogic, (String) evt.getItem());
        initFields(cbxPK, (String) evt.getItem());
    }//from   w w w.j a va 2s.  c om
}

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);/*from   ww  w.  j av a 2s.  c  om*/
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}

From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *//* w ww  .ja v a 2s. com*/
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getHaplotypeDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                HaplotypeAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:MenuDemo.java

public void itemStateChanged(ItemEvent e) {
    JMenuItem source = (JMenuItem) (e.getSource());
    String s = "Item event detected." + newline + "    Event source: " + source.getText() + " (an instance of "
            + getClassName(source) + ")" + newline + "    New state: "
            + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected" : "unselected");
    output.append(s + newline);//w  ww .j  a v  a  2  s . co  m
    output.setCaretPosition(output.getDocument().getLength());
}

From source file:org.jax.bham.test.MultiHaplotypeBlockTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *///from   w  w w  .j a  v  a 2 s  . c  o  m
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities.toIntegerList(this.testToPlot.getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                MultiHaplotypeBlockTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:daylightchart.gui.DaylightChartGui.java

private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) {

    final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$
    menu.setMnemonic('O');

    final GuiAction options = new OptionsAction(this);
    menu.add(options);/*from  w  w w .j av a  2s.  c  om*/

    final GuiAction chartOptions = new ChartOptionsAction(this);
    menu.add(chartOptions);

    final GuiAction resetAll = new ResetAllAction(this);
    menu.add(resetAll);

    menu.addSeparator();

    final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem(
            Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$
    slimUiMenuItem.setState(isSlimUi());
    slimUiMenuItem.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(final ItemEvent e) {
            final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED;
            final Options options = UserPreferences.optionsFile().getData();
            options.setSlimUi(slimUi);
            UserPreferences.optionsFile().save(options);
            ResetAllAction.restart(DaylightChartGui.this, slimUi);
        }
    });
    menu.add(slimUiMenuItem);

    menuBar.add(menu);

    toolBar.add(options);
    toolBar.add(chartOptions);
    toolBar.addSeparator();
}

From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *//*from  ww  w .j a  v a 2 s  . c om*/
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getPhylogenyDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                PhylogenyAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}