RSS Forums RSS

adding a JFrame component to JTabbedPane

Please support our Java advertiser: Programming Forums
Reply
Posts: 125
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

  #1  
Jan 8th, 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.

// 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.
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,957
Reputation: masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold 
Solved Threads: 198
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: adding a JFrame component to JTabbedPane

  #2  
Jan 9th, 2008
A JFrame is a top-level component. It can not be "added" to another. Use a JPanel.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Posts: 137
Reputation: PoovenM is on a distinguished road 
Solved Threads: 11
PoovenM PoovenM is offline Offline
Junior Poster

Troubleshooting Re: adding a JFrame component to JTabbedPane

  #3  
Jan 9th, 2008
I agree with Masijade, and I think you could probably just change the JFrame inheritance to JPanel, well depending on your actual coding hehe Anyway, what I wanted to recommend is NetBeans. It’s a very innovate IDE when one is dealing with GUI applications You’d just create a new Java project and create a new GUI form; then you can drag and drop components just like in Visual Basic, but since it's Java it's better You certainly don’t have to code within NetBeans; just copy the automatically generated GUI code to the IDE that you’re using.
Last edited by PoovenM : Jan 9th, 2008 at 2:28 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 2553 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:35 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC