I keep receiving the error:
Exception in thread \"main\" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.checkNotA
EmployeeGUI
extends from JFrame
, but in your main
method, you are creating a new JFrame
and are trying to add an instance of EmployeeGUI
to it.
Change EmployeeGUI
so it extends from JPanel
instead
Here:
frame.getContentPane().add(app, BorderLayout.CENTER);
you're trying to add a JFrame to a JFrame which makes no sense.
Why not instead just try to display app rather than add it to a JFrame. Or even better, not have EmployeeGUI extend JFrame.
You can't add a JFrame to another JFrame. But you can add a JPanel to a JFrame, in other words change EmployeeGUI to make it extends JPanel.