|
|
@@ -11,6 +11,8 @@ import java.util.Locale;
|
|
|
import javax.swing.event.DocumentListener;
|
|
|
import javax.swing.text.NumberFormatter;
|
|
|
|
|
|
+import org.leumasjaffe.recipe.model.Ingredient;
|
|
|
+
|
|
|
import javax.swing.JFormattedTextField;
|
|
|
import java.awt.Font;
|
|
|
import javax.swing.JLabel;
|
|
|
@@ -20,7 +22,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
private JTextField txtName;
|
|
|
private JTextField txtUnit;
|
|
|
|
|
|
- public IngredientPanel() {
|
|
|
+ public IngredientPanel(final Ingredient ingredient) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 100, 40, 40, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
@@ -36,7 +38,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
gbc_label.gridy = 0;
|
|
|
add(label, gbc_label);
|
|
|
|
|
|
- txtName = new JTextField();
|
|
|
+ txtName = new JTextField(ingredient.getName());
|
|
|
txtName.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
|
gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
|
|
|
@@ -50,6 +52,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
fmtDone.setMinimum(0.0);
|
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
|
JFormattedTextField txtAmount = new JFormattedTextField(fmtDone);
|
|
|
+ txtAmount.setValue(ingredient.getAmount().getValue());
|
|
|
txtAmount.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtAmount = new GridBagConstraints();
|
|
|
gbc_txtAmount.fill = GridBagConstraints.HORIZONTAL;
|
|
|
@@ -59,7 +62,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
add(txtAmount, gbc_txtAmount);
|
|
|
txtAmount.setColumns(4);
|
|
|
|
|
|
- txtUnit = new JTextField();
|
|
|
+ txtUnit = new JTextField(ingredient.getAmount().unitName());
|
|
|
txtUnit.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtUnit = new GridBagConstraints();
|
|
|
gbc_txtUnit.anchor = GridBagConstraints.ABOVE_BASELINE;
|