Hello folks,
I am trying to add a JFrame object into JTabbedPane, but I am getting a java.lang.IllegalArgumentException. Here's my code snipt.
// other codes...
JTabbedPane tabs = new JTabbedPane();
tabs.addTab("Flight Information",flightInfoPane); <-------------- line 28
// other codes...
private FlightInfoPane flightInfoPane = new FlightInfoPane();
Here I have flightInfoPane class's declaration...
class FlightInfoPane extends JFrame {
public FlightInfoPane () {
}
// rest of the class ....
}
This is the error that I am getting. I am not sure if this operation is allowed.
F:\DCTM_WORK>java FlightReservationDesktop.Reservation
Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Unknown Source)
at javax.swing.JTabbedPane.insertTab(Unknown Source)
at javax.swing.JTabbedPane.addTab(Unknown Source)
at FlightReservationDesktop.Reservation.<init>(Reservation.java:28)
at FlightReservationDesktop.Reservation.main(Reservation.java:35)
please advise...
Thanks.