JInternalFrame is a lightweight object that provides many of the features of a native frame, including dragging, closing, becoming an icon, resizing, title display, and support for a menu bar. Generally, JInternalFrames are added to a JDesktopPane.
To use JInternalFrame using program:-
To use JInternalFrame using program:-
UseInternalFrm.java
import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
class UseInternalFrm extends JFrame
{
JButton btn;
JDesktopPane deskTop;
UseInternalFrm()
{
super("JInternalFrame"); //setTitle("JInternalFrame");
deskTop=new JDesktopPane();
setContentPane(deskTop);
setLayout(null);
btn=new JButton("JInternalFrame");
add(btn);
btn.setBounds(200,70,140,30);
btn.addActionListener(new ActionListener(){ //anonymous inner classes
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{
InternalFrm frm=new InternalFrm();
deskTop.add(frm);
frm.setLocation(250,140);
}
} });
setBounds(150,200,600,550);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String arg[])
{
new UseInternalFrm();
}
}//close of class UseInternalFrm
InternalFrm.java
import javax.swing.*;
class InternalFrm extends JInternalFrame
{
InternalFrm()
{
super("JInternalFrame",false,true,false,true); //super("string title",boolean resizable,boolean frame_close,boolean frame_maximize,boolean frame_minimize)
JLabel jlb=new JLabel("Showing Label");
add(jlb);
setVisible(true);
setBounds(150,200,300,250);
}
}//close of class InternalFrm
Here is the Output:-

No comments:
Post a Comment