by Dinesh Thakur

An internal frame is similar to a regular frame which can be displayed within another window. It is a lightweight component which can be resized, closed, maximized or minimized depending upon the properties being set. It can also hold a title and a menu bar. An internal frame is an object of JinternalFrame class.

Some of the constructors defined by JinternalFrame class are as follows:

JinternalFrame()

JinternalFrame(String title)

JinternalFrame(String title, boolean resizable)

JinternalFrame(String title, boolean resizable, closable, boolean maximizable, boolean iconifiable)

where,

title specifies the title of the frame

resizable can have one of the two values: true, if the internal frame is resizable; otherwise false (default value)

closable can have one of the two values: true, if the internal frame is closeable, otherwise false (default value)

maximizable can have one of the two values: true, if the internal frame is maximizable, otherwise false (default value)

iconifiable can have one of the two values: true, if the internal frame is minimizable, otherwise false (default value)

The internal frame requires desktop pane which is capable of handling it. The purpose of desktop pane is to hold and manage the working of internal frames. A desktop pane is an object of JDesktopPane class and can be created by using its only constructor JDesktopPane ().

import javax.swing.*;

public class JInternalFrameJavaExample extends JFrame
{
     public JInternalFrameJavaExample()
    {
       super();
    }
    public static void main(java.lang.String[] args)
    {
        JInternalFrameJavaExample InternalFrame = new JInternalFrameJavaExample();
        InternalFrame.pack();
        InternalFrame.setSize(500, 200);
        JInternalFrame IFrame = new JInternalFrame();
        IFrame.setVisible(true);
        IFrame.setTitle("JInternalFrame Example");
        InternalFrame.getContentPane().add(IFrame);
        InternalFrame.setTitle("JInternalFrame Example in Java Swing");
        InternalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        InternalFrame.setVisible(true);
    }
}

JInternalFrame Example in Java Swing