• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding a window to a container

 
Pranay Narotam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have a table screen, and if a user right clicks on a specific row, than a pop up menu will appear, and if a
user chooses an option from the pop up menu, than another screen will appear displaying information relating to
the table row.

This is all working fine. The screen appears and displays the relevant information. However, when the screen appears,
I get an exception telling me "ADDING A WINDOW TO A CONTAINER". And, the whole application freezes.

This is snippets from the code that i am using:




and this is the exception that im getting
Exception occurred during event dispatching:
java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Container.java:1010)
at java.awt.Container.add(Container.java:928)
at javax.swing.JFrame.addImpl(JFrame.java:479)
at java.awt.Container.add(Container.java:351)



Thanks
Your help will be greatly appreciated

pranay
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> This is snippets from the code that i am using:

if you don't know what the problem is, how do you know it's in those snippets?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "TariffBaseLookupProperties" extending? I strongly suspect JFrame because of

Your problem is because of
JFrame is a "top level container" and as such it cannot be "added' to any other container.
 
Pranay Narotam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

When I debug through the code the exception comes up by



and sorry if I didn't make it clear. but my problem is that the whole program freezes when
this specific screen is loaded screen is loaded. I do not know why this is happening.

For "TariffBaseLookupProperties" class, I extended JFrame.

Thanks

pranay

 
Pranay Narotam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks Maneesh. It is extending JFrame. So if i shouldn't extend JFrame, than
what should i extend?


Thanks
pranay
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it will only be used inside windows, extend JPanel. You can always add that to another JFrame / JDialog if needed.
 
Pranay Narotam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks Rob and Maneesh. It does work, and i no longer get an exception.

But now I discovered another problem.

The screen comes up when you select it from the popup menu. but it is only
focusable when i close the previous window.
I cannot close or do anything to that screen unless the previous screen is closed.
I did use the setFocusable() and setEnabled() methods but I still can't do anything to
the screen.

Any ideas as to why this is happening will be greatly appreciated.

Thanks again for your help to my previous problem.

pranay
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about posting your code so we can figure out whats going wrong?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic