I have an application, that changes its interface due to users actions (i.e., an installation program). The question is: how to organize switching these pages
and building place - build everything in the main constructor, if the class inherits JFrame, or the method that buids up the interface (like createAndShowGui
in Oracle's tutorials) - or - provide a method that returns JPanel
which represents needed page.
Or, like this
class UI extends JFrame {
private Page1 page1;
private Page2 page2;
//...
public UI() { /* Main UI and switching */ }
private class Page1 extends JPanel {
/* ... */
}
private class Page2 extends JPanel {
/* ... */
}
}