-public class FirstnameView {
+import javax.swing.*;
+
+public class FirstnameView extends JComponent {
private Firstname firstnameObj;
+ private JTextField textField;
+ private JLabel label;
- FirstnameView(Firstname firstnameObj) {
- setFirstnameObj(firstnameObj);
+ FirstnameView(int length) {
+ this.label = new JLabel();
+ this.label.setText("Firstname");
+ this.textField = new JTextField(length);
+ if (firstnameObj != null) {
+ this.textField.setText(this.firstnameObj.getFirstname());
+ }
+ add(label);
+ add(textField);
}
public Firstname getFirstnameObj() {