Example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel

List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel

Introduction

In this page you can find the example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel.

Prototype

public DefaultComboBoxModel(Vector<E> v) 

Source Link

Document

Constructs a DefaultComboBoxModel object initialized with a vector.

Usage

From source file:com.peterbochs.instrument.InstrumentPanel.java

private JComboBox getJSpeedComboBox() {
    if (jSpeedComboBox == null) {
        ComboBoxModel jSpeedComboBoxModel = new DefaultComboBoxModel(
                new String[] { "100ms", "200ms", "250ms", "500ms", "1s", "2s", "5s", "10s" });
        jSpeedComboBox = new JComboBox();
        jSpeedComboBox.setModel(jSpeedComboBoxModel);
        jSpeedComboBox.setPreferredSize(new java.awt.Dimension(97, 22));
        jSpeedComboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                jSpeedComboBoxActionPerformed(evt);
            }/*  w ww.j  a v  a  2  s  .com*/
        });
    }
    return jSpeedComboBox;
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private JComboBox getJChartBackgroundComboBox() {
    if (jChartBackgroundComboBox == null) {
        ComboBoxModel jChartBackgroundComboBoxModel = new DefaultComboBoxModel(
                new Color[] { Color.black, Color.gray, Color.lightGray, Color.blue, Color.white });
        jChartBackgroundComboBox = new JComboBox();
        jChartBackgroundComboBox.setModel(jChartBackgroundComboBoxModel);
        jChartBackgroundComboBox.setRenderer(new ComboBoxRenderer());
        jChartBackgroundComboBox.setPreferredSize(new java.awt.Dimension(67, 22));
        jChartBackgroundComboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                jChartBackgroundComboBoxActionPerformed(evt);
            }/* w  ww  .j  a v  a  2  s. c om*/
        });
    }
    return jChartBackgroundComboBox;
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private JComboBox getJChartGirdColorComboBox() {
    if (jChartGirdColorComboBox == null) {
        ComboBoxModel jChartGirdColorComboBoxModel = new DefaultComboBoxModel(new Color[] { Color.green,
                Color.lightGray, Color.white, Color.black, Color.yellow, Color.red, Color.blue });
        jChartGirdColorComboBox = new JComboBox();
        jChartGirdColorComboBox.setModel(jChartGirdColorComboBoxModel);
        jChartGirdColorComboBox.setPreferredSize(new java.awt.Dimension(71, 22));
        jChartGirdColorComboBox.setRenderer(new ComboBoxRenderer());
        jChartGirdColorComboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                jChartGirdColorComboBoxActionPerformed(evt);
            }//w  w w.j  ava 2 s .  c  o  m
        });
    }
    return jChartGirdColorComboBox;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jTextField   
 *    //from w w  w .ja  v a  2 s  .c  om
 * @return javax.swing.JTextField   
 */
private JComboBox getJTextField5() {
    if (jComboBoxFamily == null) {
        jComboBoxFamily = new JComboBox<String>();
        jComboBoxFamily.setModel(new DefaultComboBoxModel<String>(HigherTaxonLifeCycle.selectDistinctFamily()));
        jComboBoxFamily.setEditable(true);
        //jTextFieldFamily.setInputVerifier(MetadataRetriever.getInputVerifier(Specimen.class, "Family", jTextFieldFamily));
        jComboBoxFamily.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Family"));
        jComboBoxFamily.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });
        AutoCompleteDecorator.decorate(jComboBoxFamily);
    }
    return jComboBoxFamily;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jTextField1   
 *    //from  w  ww  .jav  a  2 s  .co  m
 * @return javax.swing.JTextField   
 */
private JComboBox getJTextFieldSubfamily() {
    if (jComboBoxSubfamily == null) {
        jComboBoxSubfamily = new JComboBox<String>();
        jComboBoxSubfamily
                .setModel(new DefaultComboBoxModel<String>(HigherTaxonLifeCycle.selectDistinctSubfamily("")));
        jComboBoxSubfamily.setEditable(true);
        //jTextFieldSubfamily.setInputVerifier(MetadataRetriever.getInputVerifier(Specimen.class, "Subfamily", jTextFieldSubfamily));
        jComboBoxSubfamily.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Subfamily"));
        jComboBoxSubfamily.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });
        AutoCompleteDecorator.decorate(jComboBoxSubfamily);
    }
    return jComboBoxSubfamily;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jComboBoxSex   
 *    /*from   w  w w . jav  a 2 s  .co m*/
 * @return javax.swing.JComboBox   
 */
private JComboBox getJComboBoxSex() {
    if (jComboBoxSex == null) {
        jComboBoxSex = new JComboBox<String>();
        jComboBoxSex.setModel(new DefaultComboBoxModel<String>(Sex.getSexValues()));
        jComboBoxSex.setEditable(true);
        jComboBoxSex.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Sex"));
        jComboBoxSex.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });
        AutoCompleteDecorator.decorate(jComboBoxSex);
    }
    return jComboBoxSex;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jComboBoxFeatures   
 *    /* w ww . j  a  v a  2 s . c o  m*/
 * @return javax.swing.JComboBox   
 */
private JComboBox getJComboBoxFeatures() {
    if (jComboBoxFeatures == null) {
        jComboBoxFeatures = new JComboBox<String>();
        jComboBoxFeatures.setModel(new DefaultComboBoxModel<String>(Features.getFeaturesValues()));
        jComboBoxFeatures.setEditable(true);
        jComboBoxFeatures.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Features"));
        jComboBoxFeatures.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });
        AutoCompleteDecorator.decorate(jComboBoxFeatures);
        // TODO: validate input length 
    }
    return jComboBoxFeatures;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

private JComboBox<String> getJComboBoxNatureOfId() {
    if (jComboBoxNatureOfId == null) {
        jComboBoxNatureOfId = new JComboBox<String>();
        jComboBoxNatureOfId.setModel(new DefaultComboBoxModel<String>(NatureOfId.getNatureOfIdValues()));
        jComboBoxNatureOfId.setEditable(false);
        jComboBoxNatureOfId.setToolTipText(MetadataRetriever.getFieldHelp(Determination.class, "NatureOfId"));
        jComboBoxNatureOfId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }//from  w  w  w .ja  v  a 2  s  .c o m
        });
        AutoCompleteDecorator.decorate(jComboBoxNatureOfId);
    }
    return jComboBoxNatureOfId;
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jComboBoxLifeStage   
 *    /*  w  w  w  .ja  v  a 2  s.c  o  m*/
 * @return javax.swing.JComboBox   
 */
private JComboBox<String> getJComboBoxLifeStage() {
    if (jComboBoxLifeStage == null) {
        jComboBoxLifeStage = new JComboBox<String>();
        jComboBoxLifeStage.setModel(new DefaultComboBoxModel<String>(LifeStage.getLifeStageValues()));
        jComboBoxLifeStage.setEditable(true);
        jComboBoxLifeStage.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Lifestage"));
        jComboBoxLifeStage.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });
        AutoCompleteDecorator.decorate(jComboBoxLifeStage);
    }
    return jComboBoxLifeStage;
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

private void fireAddROIDoneEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireAddROIDoneEvent

    if (evt.getSource() == jAddNewROIButton) {
        try {/*w w  w.jav  a  2s . co  m*/
            int x = UIHelper.parseIntFromField(jCenterX, (int) dCenterX);
            int y = UIHelper.parseIntFromField(jCenterY, (int) dCenterY);
            String value = jROITextField.getText() + " (" + x + "|" + y + ")";
            int pos = Integer.MAX_VALUE;
            try {
                pos = Integer.parseInt((String) jROIPosition.getSelectedItem());
                pos -= 1;
            } catch (Exception ee) {
                //end pos selected
                pos = Integer.MAX_VALUE;
            }

            if (ROIManager.getSingleton().containsROI(value)) {
                JOptionPaneHelper.showWarningBox(this, "ROI '" + value + "' existiert bereits.",
                        "ROI vorhanden");
                return;

            }

            ROIManager.getSingleton().addROI(pos, value);
            jROIBox.setModel(new DefaultComboBoxModel(ROIManager.getSingleton().getROIs()));
        } catch (Exception e) {
            logger.error("Failed to add ROI", e);
        }

    }
    jAddROIDialog.setVisible(false);

}