Search code examples
javaswingappletjpaneljinternalframe

How to create internal frames (child frames) in an applet


I am trying to create a child frame to exist inside my applet and it should be bound to a JPanel. I found this and that on the internet but nothing that worked. I think something went wrong during the process and the darn thing is hidden or something. Can someone please give me some help on this issue.

My source code follows...

public class EnableFrame {

  public void init() {

    EnableFrame theframe = new EnableFrame();
    theframe.setSize(550, 300);
    theframe.setVisible(true);
  }

  public EnableFrame()  {

    JPanel containall = new JPanel();

    JInternalFrame iframe = new JInternalFrame("New Frame",true,true);
    iframe.setBounds(10,10,150,150);
    iframe.getContentPane().add(containall);
    iframe.show(true);
  }
}

Thanks in advance

-Roland


Solution

  • A JInternal is normally associated with a JDesktopPane.

    I order for the internal frame to appear on the screen, you must have added the frame to an appropriate container, such as a JDesktopPane

    You may find How to Use Internal Frames of some use.