?
-
when designing a GUI, should reusability be taken into account for the
class as well the methods?
e.g an internal frame with a display area and an input area.
1) no 'extends'
public class SampleIFrame {
private JComponent display;
private JComponent input;
private SampleIFrame() {
}
public static JComponent createWindow() {
display = createDisplay();
input = createInput();
...
...
}
public JComponent getDisplay() {
return display;
}
public JComponent getInput() {
return input;
}
protected JComponent createDisplay() {
return new JTextArea();
}
protected JComponent createInput() {
return new JTextField();
}
}
2) with 'extends'
public class SampleIFrame extends JInternalFrame {
private JComponent display;
private JComponent input;
private SampleIFrame() {
display = createDisplay();
input = createInput();
...
...
}
...
...
}
or if there are nicer ways to do it, please share it with me...
class as well the methods?
e.g an internal frame with a display area and an input area.
1) no 'extends'
public class SampleIFrame {
private JComponent display;
private JComponent input;
private SampleIFrame() {
}
public static JComponent createWindow() {
display = createDisplay();
input = createInput();
...
...
}
public JComponent getDisplay() {
return display;
}
public JComponent getInput() {
return input;
}
protected JComponent createDisplay() {
return new JTextArea();
}
protected JComponent createInput() {
return new JTextField();
}
}
2) with 'extends'
public class SampleIFrame extends JInternalFrame {
private JComponent display;
private JComponent input;
private SampleIFrame() {
display = createDisplay();
input = createInput();
...
...
}
...
...
}
or if there are nicer ways to do it, please share it with me...