Results 1 to 4 of 4
- 04-15-2012, 08:39 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 20
- Rep Power
- 0
JDialog and "adding a window to a container" error
I am attempting to create a GPA Calculator. After requesting input from the user regarding thier grades, my plan was to have a JDialog pop up and display thier GPA ( Grade Point Average). The program runs fine untill i click on the "Calculate" Button at which point the following error appears on the console:
The only line in the error that points to my code points to thisException in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.checkNotAWindow(Container.java: 431)
at java.awt.Container.addImpl(Container.java:1039)
at java.awt.Container.add(Container.java:365)
at messageBox.<init>(messageBox.java:43)
at GPACalculatorFrame$1ButtonListener.actionPerformed (GPACalculatorFrame.java:288)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.jav a:6373)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:613 8)
at java.awt.Container.processEvent(Container.java:208 5)
at java.awt.Component.dispatchEventImpl(Component.jav a:4735)
at java.awt.Container.dispatchEventImpl(Container.jav a:2143)
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4621)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4212)
at java.awt.Container.dispatchEventImpl(Container.jav a:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478 )
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:679)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:638)
at java.awt.EventQueue$1.run(EventQueue.java:636)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:652)
at java.awt.EventQueue$2.run(EventQueue.java:650)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 649)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
Does anyone know what might be causing this problem and how to fix itGPACalculator kad = new GPACalculator(lo);
messageBox message = new messageBox(kad);
p.s to my credit if anything doesn't really make sense in this post its probably due to the fact that im exhausted by two nights in a row of nearly no sleep
- 04-15-2012, 09:14 AM #2
Re: JDialog and "adding a window to a container" error
Moved from New to Java.
The error means exactly what the message says: you can't add a top level window to a Container. Since we haven't a clue what's in your GPACalculator and (badly-named*) messageBox classes, we can't shed any more light on the problem than that.
Why do you even have a custom class for a message box? If it does what its name implies, you should probably be using the static methods of JOptionPane and not reinventing the wheel.
db
* Code Conventions for the Java Programming Language: Contents -- class names start with an uppercase letter.Why do they call it rush hour when nothing moves? - Robin Williams
- 04-15-2012, 09:26 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 20
- Rep Power
- 0
Re: JDialog and "adding a window to a container" error
Great suggestions and thank you, solved the problem
- 04-15-2012, 09:37 AM #4
Similar Threads
-
IllegalArgumentException: adding a window to a container
By aborgeld in forum Advanced JavaReplies: 3Last Post: 03-24-2011, 06:18 AM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 07:58 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
How to check a "connection" from datasource is in Container and part of Transaction
By alexendra in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 05-24-2008, 08:51 AM -
How to check a "connection" from datasource is in Container and part of Transaction
By alexendra in forum JDBCReplies: 0Last Post: 05-24-2008, 08:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks