I'm new to swing, and I'm trying to implement a simple GUI with one form (HospitalGUI.form). When I run the associated Java file (HospitalGUI.java) as main, the form is visible.
I want to be able to launch it from my controller so that either the GUI or a console interface can be selected. When my controller instantiates it, the code in the constructor is executed, but the form doesn't open.
Is there anything special or additional that needs to be done for a form to be opened by another Object?
I would greatly appreciate any help understanding this.
My GUI's main is
public static void main(String[] args) {
final int FRAME_WIDTH = 300;
final int FRAME_HEIGHT = 400;
JFrame frame = new JFrame("Hospital System");
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setContentPane(new HospitalGUI().rootPanel);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
and the call in the controller is
HospitalGUI hospitalInterface = new HospitalGUI();