JDesktop Pane and Internal Frames

Ok here goes. What I would like to do is have a class that acts as a "Base". It will consist of a JDesktop Pane, on which i can load different classes for different purposes.

My current app consists of a JDesktopPane, with a JInternalFrame on which i have 3 tabs with the necessary actions. I was asked to add a new thing to the app, and I feel that I would like to segment it a little bit.

So back to what I'm trying to do. MainUI with a JDesktopPane. How can i call the already existing class (TaxiLogUI). The TaxiLogUI has all the code to create a JInternalFrame. In theory I thought I could, in MainUI, create a new TaxiLogUI object and add it to the JDesktopPane.

publicclass MainUIextends javax.swing.JFrame{

/** Creates new form MainUI */

public MainUI(){

initComponents();

TaxiLogUI test=new TaxiLogUI();

Desktop.add(test);

}

(Desktop initialized in initComponents())

All compiles fine, but i get an error when i try to run it:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container

Why is this? What can I do to accomplish what I'm trying to do?

Summary:

*Have a working app (TaxiLobUI) that includes a JDesktopPane, JInternalFrame etc... took out the JDesktop Pane so it just creates a JInternalFrame.

*Would like an app to act as a "Base" for different tasks (MainUI), would like to create a JInteralFrame with the contents from TaxiLogUI

*Getting exception about adding a window to a container

Any help, or even a hint to which direction to look would be much appreciated. Thanks!

[1940 byte] By [Jensenryaa] at [2007-11-26 17:43:11]
# 1

The error message says it all, you can't add a JWindow to a Container. A JWindow is a top level container (like JFrame, JDialog). You add JComponents (JDesktopPane, JTextField, JLabel...) to Containers.

A JDesktopPane was designed to only hold JInternalFrames.

I really don't understand what you are trying to accomplish, but I think you should be looking at using a [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout[/url]. This will allow you to reuse the space in the JFrame with different panels.

camickra at 2007-7-9 0:11:22 > top of Java-index,Desktop,Core GUI APIs...