Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Awt vs. Swing error

 
Patrick ODonnell
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I get the following error when I try to drag a JInternalFrame which is inside a JDesktopPane.
I think this is because I am adding a JInternalFrame to a container before it is viewed.
The reason I add it to a container is I have set the DesktopPane layout to BorderLayout and the container is in the BorderLayout.CENTER region which is where I want the JInternalFrame to appear. The container keeps the JInternalFrames the correct size.
My question is what can I use instead of a awt.container to hold my JInternalFrames??
Exception occurred during event dispatching:
java.lang.ClassCastException: java.awt.Container
at javax.swing.DefaultDesktopManager.dragFrameFaster(DefaultDesktopManager.java:533)
at javax.swing.DefaultDesktopManager.dragFrame(DefaultDesktopManager.java:280)
Any help would be greatly appreciated
Thanks,
Patrick.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way to add JInternalFrames to a JDesktopPane is as follows:

Hope that helps a little. To answer your question, you set the JDesktopPane as the ContentPane of your JFrame. This uses a SWING Container for the JInternalFrames.
There are a few elements missing from the code, like a Window Listener for your JFrame and things like that, but this should give you a general idea.
[ February 13, 2002: Message edited by: Gregg Bolinger ]
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!