Stripies
Stripies

Reputation: 1267

Java - Another JFrame On Same Window

What I want is to make a new JFrame, keeping my current JFrame visible, but not create a new window/program. I can't explain it well, so here is a picture of what I mean:

http://screensnapr.com/e/mkCMlm.png

Sorry if this is confusing in any way. Any help is appreciated.

Upvotes: 0

Views: 2296

Answers (2)

Necronet
Necronet

Reputation: 6813

If I understood correctly you want JInternalFrame which are a special component in swing that live inside a Container named Desktop. So if you want to have a behaviour like this:

enter image description here

You definitely need to have inside your JFrame a container named JDesktopPane, then you can add JInternalFrame inside this container like this:

 MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame);
    try {
        frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {ex.printStackTrace();}

For more information you can see official oracle documentation or Java2SE code samples

Upvotes: 2

Ashwinee K Jha
Ashwinee K Jha

Reputation: 9307

You can try http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

Also you can try to use a dialog rather than frame for the new window.

Upvotes: 5

Related Questions