|
@@ -4,14 +4,20 @@ import java.awt.GridBagConstraints;
|
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagLayout;
|
|
|
import java.awt.Insets;
|
|
import java.awt.Insets;
|
|
|
|
|
|
|
|
|
|
+import javax.swing.JFormattedTextField;
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JLabel;
|
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
import org.leumasjaffe.recipe.model.Duration;
|
|
import org.leumasjaffe.recipe.model.Duration;
|
|
|
|
|
+import org.leumasjaffe.recipe.view.formatter.DurationFormatter;
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
@SuppressWarnings("serial")
|
|
|
public class DurationPanel extends JPanel {
|
|
public class DurationPanel extends JPanel {
|
|
|
- private JLabel lblTime;
|
|
|
|
|
|
|
+ private JFormattedTextField txtTime;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @wbp.parser.constructor
|
|
|
|
|
+ */
|
|
|
public DurationPanel(String name) {
|
|
public DurationPanel(String name) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
@@ -27,11 +33,11 @@ public class DurationPanel extends JPanel {
|
|
|
gbc_lblName.gridy = 0;
|
|
gbc_lblName.gridy = 0;
|
|
|
add(lblName, gbc_lblName);
|
|
add(lblName, gbc_lblName);
|
|
|
|
|
|
|
|
- lblTime = new JLabel();
|
|
|
|
|
- GridBagConstraints gbc_lblTime = new GridBagConstraints();
|
|
|
|
|
- gbc_lblTime.gridx = 1;
|
|
|
|
|
- gbc_lblTime.gridy = 0;
|
|
|
|
|
- add(lblTime, gbc_lblTime);
|
|
|
|
|
|
|
+ txtTime = new JFormattedTextField(new DurationFormatter());
|
|
|
|
|
+ GridBagConstraints gbc_txtTime = new GridBagConstraints();
|
|
|
|
|
+ gbc_txtTime.gridx = 1;
|
|
|
|
|
+ gbc_txtTime.gridy = 0;
|
|
|
|
|
+ add(txtTime, gbc_txtTime);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public DurationPanel(String name, Duration duration) {
|
|
public DurationPanel(String name, Duration duration) {
|
|
@@ -40,6 +46,10 @@ public class DurationPanel extends JPanel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void setModel(final Duration duration) {
|
|
public void setModel(final Duration duration) {
|
|
|
- lblTime.setText(duration.toString());
|
|
|
|
|
|
|
+ txtTime.setValue(duration);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setEditable(boolean b) {
|
|
|
|
|
+ txtTime.setEditable(b);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|