|
|
@@ -5,18 +5,12 @@ import java.awt.GridBagLayout;
|
|
|
import javax.swing.JTextField;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
-import java.awt.event.ItemEvent;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.util.Locale;
|
|
|
|
|
|
-import javax.swing.JToggleButton;
|
|
|
import javax.swing.event.DocumentListener;
|
|
|
import javax.swing.text.NumberFormatter;
|
|
|
|
|
|
-import org.leumasjaffe.recipe.model.Ingredient;
|
|
|
-
|
|
|
-import javax.swing.DefaultComboBoxModel;
|
|
|
-import javax.swing.JComboBox;
|
|
|
import javax.swing.JFormattedTextField;
|
|
|
import java.awt.Font;
|
|
|
import javax.swing.JLabel;
|
|
|
@@ -24,12 +18,13 @@ import javax.swing.JLabel;
|
|
|
@SuppressWarnings("serial")
|
|
|
public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
|
private JTextField txtName;
|
|
|
+ private JTextField txtUnit;
|
|
|
|
|
|
public IngredientPanel() {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
- gridBagLayout.columnWidths = new int[]{0, 100, 40, 0, 0, 0};
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 100, 40, 40, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
- gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
+ gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
setLayout(gridBagLayout);
|
|
|
|
|
|
@@ -64,38 +59,15 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
add(txtAmount, gbc_txtAmount);
|
|
|
txtAmount.setColumns(4);
|
|
|
|
|
|
- JToggleButton tglbtnUnits = new JToggleButton("vol");
|
|
|
- tglbtnUnits.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
- tglbtnUnits.setMargin(new Insets(2, 5, 2, 5));
|
|
|
- GridBagConstraints gbc_tglbtnUnits = new GridBagConstraints();
|
|
|
- gbc_tglbtnUnits.insets = new Insets(0, 0, 0, 5);
|
|
|
- gbc_tglbtnUnits.gridx = 3;
|
|
|
- gbc_tglbtnUnits.gridy = 0;
|
|
|
- add(tglbtnUnits, gbc_tglbtnUnits);
|
|
|
-
|
|
|
- JComboBox<Ingredient.Weight> weights = new JComboBox<>(new DefaultComboBoxModel<>(Ingredient.Weight.values()));
|
|
|
- weights.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
- JComboBox<Ingredient.Volume> volumes = new JComboBox<>(new DefaultComboBoxModel<>(Ingredient.Volume.values()));
|
|
|
- volumes.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
- GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
|
|
- gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
|
|
|
- gbc_comboBox.gridx = 4;
|
|
|
- gbc_comboBox.gridy = 0;
|
|
|
- add(volumes, gbc_comboBox);
|
|
|
-// add(weights, gbc_comboBox);
|
|
|
-
|
|
|
- tglbtnUnits.addItemListener(e -> {
|
|
|
- if (e.getStateChange() == ItemEvent.SELECTED) {
|
|
|
- tglbtnUnits.setText("wgt");
|
|
|
- remove(volumes);
|
|
|
- add(weights, gbc_comboBox);
|
|
|
- } else {
|
|
|
- tglbtnUnits.setText("vol");
|
|
|
- remove(weights);
|
|
|
- add(volumes, gbc_comboBox);
|
|
|
- }
|
|
|
- repaint();
|
|
|
- });
|
|
|
+ txtUnit = new JTextField();
|
|
|
+ txtUnit.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
+ GridBagConstraints gbc_txtUnit = new GridBagConstraints();
|
|
|
+ gbc_txtUnit.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
|
+ gbc_txtUnit.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_txtUnit.gridx = 3;
|
|
|
+ gbc_txtUnit.gridy = 0;
|
|
|
+ add(txtUnit, gbc_txtUnit);
|
|
|
+ txtUnit.setColumns(10);
|
|
|
}
|
|
|
|
|
|
@Override
|