Example usage for javax.swing JTextField setVerifyInputWhenFocusTarget

List of usage examples for javax.swing JTextField setVerifyInputWhenFocusTarget

Introduction

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

Prototype

@BeanProperty(description = "Whether the Component verifies input before accepting focus.")
public void setVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget) 

Source Link

Document

Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus.

Usage

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

private void setValues() {
    log.debug("invoking setValues()");
    jTextFieldStatus.setText("Loading");

    jTextFieldBarcode.setText(specimen.getBarcode());
    jComboBoxLocationInCollection.setSelectedItem(specimen.getLocationInCollection());
    cbTypeStatus.setSelectedItem(specimen.getTypeStatus());
    jTextFieldDrawerNumber.setText(specimen.getDrawerNumber());
    jComboBoxFamily.setSelectedItem(specimen.getFamily());
    jComboBoxSubfamily.setSelectedItem(specimen.getSubfamily());
    jTextFieldTribe.setText(specimen.getTribe());
    jTextFieldGenus.setText(specimen.getGenus());
    jTextFieldSpecies.setText(specimen.getSpecificEpithet());
    jTextFieldSubspecies.setText(specimen.getSubspecificEpithet());
    jTextFieldInfraspecificEpithet.setText(specimen.getInfraspecificEpithet());
    jTextFieldInfraspecificRank.setText(specimen.getInfraspecificRank());
    jTextFieldAuthorship.setText(specimen.getAuthorship());

    jTextFieldIdRemarks.setText(specimen.getIdentificationRemarks());
    jTextFieldDateDetermined.setText(specimen.getDateIdentified());

    MCZbaseAuthAgentName selection = new MCZbaseAuthAgentName();
    selection.setAgent_name(specimen.getIdentifiedBy());
    ((AgentNameComboBoxModel) jCBDeterminer.getModel()).setSelectedItem(selection);
    jCBDeterminer.getEditor().setItem(jCBDeterminer.getModel().getSelectedItem());

    jComboBoxNatureOfId.setSelectedItem(specimen.getNatureOfId());

    jTextFieldUnnamedForm.setText(specimen.getUnNamedForm());
    jTextFieldVerbatimLocality.setText(specimen.getVerbatimLocality());
    // Specimen record contains a string, delegate handling of lookup of object to the combo box model.
    log.debug(specimen.getHigherGeography());
    ((HigherGeographyComboBoxModel) comboBoxHigherGeog.getModel())
            .setSelectedItem(specimen.getHigherGeography());
    //TODO ? set model not notifying listeners?       
    comboBoxHigherGeog.getEditor().setItem(comboBoxHigherGeog.getModel().getSelectedItem());
    jTextFieldCountry.setText(specimen.getCountry());
    if (specimen.getValidDistributionFlag() != null) {
        jCheckBoxValidDistributionFlag.setSelected(specimen.getValidDistributionFlag());
    } else {//from   ww w  .j  a  v a 2 s .c om
        jCheckBoxValidDistributionFlag.setSelected(false);
    }
    jTextFieldPrimaryDivision.setText(specimen.getPrimaryDivison());
    jTextFieldLocality.setText(specimen.getSpecificLocality());

    // Elevations  **********************************************************************
    try {
        jTextFieldMinElevation.setText(Long.toString(specimen.getMinimum_elevation()));
    } catch (Exception e) {
        jTextFieldMinElevation.setText("");
    }
    try {
        textFieldMaxElev.setText(Long.toString(specimen.getMaximum_elevation()));
    } catch (Exception e) {
        textFieldMaxElev.setText("");
    }
    if (specimen.getElev_units() != null) {
        comboBoxElevUnits.setSelectedItem(specimen.getElev_units());
    } else {
        comboBoxElevUnits.setSelectedItem("");
    }

    jTextFieldCollectingMethod.setText(specimen.getCollectingMethod());
    jTextFieldISODate.setText(specimen.getIsoDate());
    jTextFieldDateNos.setText(specimen.getDateNos());
    jTextFieldDateCollected.setText(specimen.getDateCollected());
    jTextFieldDateEmerged.setText(specimen.getDateEmerged());
    jTextFieldDateCollectedIndicator.setText(specimen.getDateCollectedIndicator());
    jTextFieldDateEmergedIndicator.setText(specimen.getDateEmergedIndicator());
    jComboBoxCollection.setSelectedItem(specimen.getCollection());
    //jTextFieldPreparationType.setText(specimen.getPreparationType());
    jTextFieldAssociatedTaxon.setText(specimen.getAssociatedTaxon());
    jTextFieldHabitat.setText(specimen.getHabitat());
    jTextAreaSpecimenNotes.setText(specimen.getSpecimenNotes());
    jComboBoxFeatures.setSelectedItem(specimen.getFeatures());
    jComboBoxLifeStage.setSelectedItem(specimen.getLifeStage());
    jComboBoxSex.setSelectedItem(specimen.getSex());
    jTextFieldCitedInPub.setText(specimen.getCitedInPublication());
    jTextFieldQuestions.setText(specimen.getQuestions());
    jComboBoxWorkflowStatus.setSelectedItem(specimen.getWorkFlowStatus());
    if (specimen.isStateDone()) {
        jLabelMigrationStatus.setText("http://mczbase.mcz.harvard.edu/guid/MCZ:Ent:" + specimen.getCatNum());
    } else {
        jLabelMigrationStatus.setText("");
    }
    jTextFieldInferences.setText(specimen.getInferences());
    jTextFieldCreator.setText(specimen.getCreatedBy());
    if (specimen.getDateCreated() != null) {
        jTextFieldDateCreated.setText(specimen.getDateCreated().toString());
    }
    jTextFieldLastUpdatedBy.setText(specimen.getLastUpdatedBy());
    if (specimen.getDateLastUpdated() != null) {
        jTextFieldDateLastUpdated.setText(specimen.getDateLastUpdated().toString());
    }

    jTableNumbers.setModel(new NumberTableModel(specimen.getNumbers()));
    // Setting the model will overwrite the existing cell editor bound 
    // to the column model, so we need to add it again.
    JTextField field1 = new JTextField();
    field1.setInputVerifier(MetadataRetriever.getInputVerifier(edu.harvard.mcz.imagecapture.data.Number.class,
            "Number", field1));
    field1.setVerifyInputWhenFocusTarget(true);
    jTableNumbers.getColumnModel().getColumn(0).setCellEditor(new ValidatingTableCellEditor(field1));
    JComboBox<String> jComboNumberTypes = new JComboBox<String>();
    jComboNumberTypes.setModel(new DefaultComboBoxModel<String>(NumberLifeCycle.getDistinctTypes()));
    jComboNumberTypes.setEditable(true);
    TableColumn typeColumn = jTableNumbers.getColumnModel().getColumn(NumberTableModel.COLUMN_TYPE);
    typeColumn.setCellEditor(new DefaultCellEditor(jComboNumberTypes));

    jTableCollectors.setModel(new CollectorTableModel(specimen.getCollectors()));
    // Setting the model will overwrite the existing cell editor bound 
    // to the column model, so we need to add it again.
    // JTextField field = new JTextField();
    FilteringAgentJComboBox field = new FilteringAgentJComboBox();
    //field.setInputVerifier(MetadataRetriever.getInputVerifier(Collector.class, "CollectorName", field));
    //jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new PicklistTableCellEditor(field, true));
    jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new ComboBoxCellEditor(field));
    //field.setInputVerifier(MetadataRetriever.getInputVerifier(Collector.class, "CollectorName", field));
    //field.setVerifyInputWhenFocusTarget(true);
    //jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new ValidatingTableCellEditor(field));

    jTableSpecimenParts.setModel(new SpecimenPartsTableModel(specimen.getSpecimenParts()));
    jTableSpecimenParts.getColumnModel().getColumn(0).setPreferredWidth(90);
    for (int i = 0; i < jTableSpecimenParts.getColumnCount(); i++) {
        TableColumn column = jTableSpecimenParts.getColumnModel().getColumn(i);
        if (i == 0) {
            column.setPreferredWidth(120);
        } else {
            column.setPreferredWidth(50);
        }
    }
    setSpecimenPartsTableCellEditors();

    updateDeterminationCount();

    if (specimen.getICImages() != null) {
        int imageCount = specimen.getICImages().size();
        jTextFieldImageCount.setText("Number of Images=" + imageCount);
        if (imageCount > 1) {
            jTextFieldImageCount.setForeground(Color.RED);
        } else {
            jTextFieldImageCount.setForeground(Color.BLACK);
        }
    }

    setWarnings();
    this.setStateToClean();
    jTextFieldStatus.setText("Loaded");
}