reusable specific gui

?

-

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top