View Single Post
Join Date: Apr 2007
Posts: 126
Reputation: new_2_java is an unknown quantity at this point 
Solved Threads: 6
new_2_java new_2_java is offline Offline
Junior Poster

adding a JFrame component to JTabbedPane

 
0
  #1
Jan 9th, 2008
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.

  1. // other codes...
  2. JTabbedPane tabs = new JTabbedPane();
  3. tabs.addTab("Flight Information",flightInfoPane); <-------------- line 28
  4. // other codes...
  5. private FlightInfoPane flightInfoPane = new FlightInfoPane();
Here I have flightInfoPane class's declaration...

  1. class FlightInfoPane extends JFrame {
  2. public FlightInfoPane () {
  3. }
  4. // rest of the class ....
  5. }

This is the error that I am getting. I am not sure if this operation is allowed.
  1. F:\DCTM_WORK>java FlightReservationDesktop.Reservation
  2. Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
  3. at java.awt.Container.addImpl(Unknown Source)
  4. at javax.swing.JTabbedPane.insertTab(Unknown Source)
  5. at javax.swing.JTabbedPane.addTab(Unknown Source)
  6. at FlightReservationDesktop.Reservation.<init>(Reservation.java:28)
  7. at FlightReservationDesktop.Reservation.main(Reservation.java:35)

please advise...


Thanks.
Reply With Quote