private void okPressed(){
        String singular = singularField.getText().trim().toLowerCase();
        String plural = pluralField.getText().trim().toLowerCase();
        if(singular.equals("")){
            JOptionPane.showMessageDialog(dialog, "You need to supply a singular name for the ingredient.\n" +
                    "The two names can be identical", "Invalid name", JOptionPane.ERROR_MESSAGE);

            singularField.requestFocusInWindow();
            return;
        }

        if(plural.equals("")){
            JOptionPane.showMessageDialog(dialog, "You need to supply a plural name for the ingredient.\n" +
                    "The two names can be identical", "Invalid name", JOptionPane.ERROR_MESSAGE);

            pluralField.requestFocusInWindow();
            return;
        }

        Ingredient tmpIngredient = new Ingredient(singular, plural, commonCheckBox.isSelected());

        if(oldIngredient != null){
            db.updateIngredient(oldIngredient, tmpIngredient);
        } else if(ingredients.contains(tmpIngredient)){
            JOptionPane.showMessageDialog(dialog, "There already exists an ingredient with this (singular) name",
                    "Ingredient exists", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        db.addIngredient(tmpIngredient);

        result = tmpIngredient;
        dialog.dispose();
    }