| | |
adding a JFrame component to JTabbedPane
![]() |
•
•
Join Date: Apr 2007
Posts: 126
Reputation:
Solved Threads: 6
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.
Here I have flightInfoPane class's declaration...
This is the error that I am getting. I am not sure if this operation is allowed.
please advise...
Thanks.
I am trying to add a JFrame object into JTabbedPane, but I am getting a java.lang.IllegalArgumentException. Here's my code snipt.
Java Syntax (Toggle Plain Text)
// other codes... JTabbedPane tabs = new JTabbedPane(); tabs.addTab("Flight Information",flightInfoPane); <-------------- line 28 // other codes... private FlightInfoPane flightInfoPane = new FlightInfoPane();
Java Syntax (Toggle Plain Text)
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.
Java Syntax (Toggle Plain Text)
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.
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
----------------------------------------------
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
•
•
Join Date: Aug 2006
Posts: 137
Reputation:
Solved Threads: 11
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 3:28 am.
![]() |
Similar Threads
- Help needed with JTree (Java)
- Source Code that don't work? (Java)
- Hey check out my prog. It has an error can u find it? (Java)
Other Threads in the Java Forum
- Previous Thread: Questions about Applet and JFrame
- Next Thread: Help needed for saving high scores
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array automation banking bidirectional binary binarytree birt bluetooth chatprogramusingobjects class classes client code color columns component count database derby design eclipse eclipsedevelopment encryption error expand fractal game givemetehcodez graphics gridlayout gui homework html if_statement image inheritance integer intellij j2me java javadesktopapplications javaprojects jlabel jme jni jpanel jtextfield julia keyword linux loop macintosh method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring netbeans newbie nullpointerexception object open-source print problem producer program projectideas property reference replaysolutions ria scanner server set size sms sourcelabs splash sql sqlite subclass support swing testautomation threads transforms tree ui unicode validation windows






