this.label = new JLabel();
this.label.setText("Firstname");
this.textField = new JTextField(length);
- this.textField.setText(firstnameObj.getFirstname());
+ this.textField.setText(this.getFirstnameObj().getFirstname());
add(label);
add(textField);
}
/**
* Create menu that support cut/copy/paste.
*/
- public JMenuBar createMenuBar() {
+ private JMenuBar createMenuBar() {
JMenuItem menuItem;
JMenuBar menuBar = new JMenuBar();
public class Size implements Comparable<Size> {
private int max = 240;
- private int min = 20;
+ private int min = 40;
private int size;
Size() {
setSize(size);
}
+ public int getMin() {
+ return min;
+ }
+
+ public int getMax() {
+ return max;
+ }
+
public int getSize() {
return size;
}
if (validateSize(size)) {
this.size = size;
} else {
- throw new IllegalArgumentException("Size must be between " + this.min + " and " + this.max);
+ throw new IllegalArgumentException("Size must be between " + this.getMin() + " and " + this.getMax());
}
}
public class SizeView extends JPanel {
private Size sizeObj;
private JLabel label;
+ private JSpinner spinner;
SizeView(Size sizeObj) {
setSizeObj(sizeObj);
this.label = new JLabel();
this.label.setText("Size");
+ SpinnerNumberModel numberModel = new SpinnerNumberModel((this.getSizeObj().getMax() - this.getSizeObj().getMin()) / 2,
+ this.getSizeObj().getMin(),
+ this.getSizeObj().getMax(),
+ 1);
+ this.spinner = new JSpinner(numberModel);
+ if (this.getSizeObj().getSize() != 0)
+ this.spinner.setValue(this.getSizeObj().getSize());
+
add(label);
+ add(spinner);
}
public Size getSizeObj() {