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