|
|
@@ -27,7 +27,7 @@ public class IngredientPanel extends JPanel {
|
|
|
@Getter(AccessLevel.PACKAGE) JFormattedTextField txtAmount;
|
|
|
@Getter(AccessLevel.PACKAGE) JTextField txtUnit;
|
|
|
|
|
|
- public IngredientPanel(final Ingredient ingredient) {
|
|
|
+ public IngredientPanel() {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
@@ -43,7 +43,7 @@ public class IngredientPanel extends JPanel {
|
|
|
gbc_label.gridy = 0;
|
|
|
add(label, gbc_label);
|
|
|
|
|
|
- txtName = new JTextField(ingredient.getName());
|
|
|
+ txtName = new JTextField();
|
|
|
txtName.setEditable(false);
|
|
|
txtName.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
|
@@ -59,7 +59,6 @@ public class IngredientPanel extends JPanel {
|
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
|
txtAmount = new JFormattedTextField(fmtDone);
|
|
|
txtAmount.setEditable(false);
|
|
|
- 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;
|
|
|
@@ -69,7 +68,7 @@ public class IngredientPanel extends JPanel {
|
|
|
add(txtAmount, gbc_txtAmount);
|
|
|
txtAmount.setColumns(4);
|
|
|
|
|
|
- txtUnit = new JTextField(ingredient.getAmount().unitName());
|
|
|
+ txtUnit = new JTextField();
|
|
|
txtUnit.setEditable(false);
|
|
|
txtUnit.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtUnit = new GridBagConstraints();
|
|
|
@@ -81,4 +80,14 @@ public class IngredientPanel extends JPanel {
|
|
|
txtUnit.setColumns(6);
|
|
|
}
|
|
|
|
|
|
+ public IngredientPanel(final Ingredient ingredient) {
|
|
|
+ this();
|
|
|
+ setModel(ingredient);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setModel(final Ingredient ingredient) {
|
|
|
+ txtName.setText(ingredient.getName());
|
|
|
+ txtAmount.setValue(ingredient.getAmount().getValue());
|
|
|
+ txtUnit.setText(ingredient.getAmount().unitName());
|
|
|
+ }
|
|
|
}
|