Examples of IngredientType


Examples of omnom.jaxb.IngredientType

    private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed
        if (nameTextField.getText() == null ? "" == null : nameTextField.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "You need a name for an ingredient");
        } else {
            IngredientType ing = new IngredientType();
            ing.setName(nameTextField.getText());
            if (amountTextField.getText() == null ? "" == null : amountTextField.getText().equals("")) {
                ing.setNumerator(0);
                ing.setDenominator(0);
            } else if (amountTextField.getText().contains("/")) {
                String[] amounts = amountTextField.getText().split("/");
                ing.setNumerator(Integer.parseInt(amounts[0]));
                ing.setDenominator(Integer.parseInt(amounts[1]));
            } else {
                ing.setDenominator(0);
                ing.setNumerator(Integer.parseInt(amountTextField.getText()));
            }
            ing.setUnit(unitTextField.getText());
            recipeParent.addIngredient(ing);
            dispose();

        }
View Full Code Here

Examples of omnom.jaxb.IngredientType

        if (item == null) {
            System.err.println("Null object");
            return null;
        }
        try {
            IngredientType ingredient = (IngredientType) item;
            String result = ingredient.getName();
            if (ingredient.getNumerator() == 0) {
                result += " " + ingredient.getUnit();
            } else if (ingredient.getDenominator() == 0) {
                result += " " + ingredient.getNumerator() + " " + ingredient.getUnit();
            } else {
                result += " " + ingredient.getNumerator() + "/" + ingredient.getDenominator() + " " + ingredient.getUnit();
            }
            return result;
        } catch (ClassCastException ex) {
            System.err.println("Class cast exception");
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.