Tuesday 7 July 2015

Filled Under:

Tutorial On Internal Frames In Java

Sometimes we need to create frames within main frame.We can do this by creating internal frame.Before creating internal frame we must have some knowledge regarding internal frames.

DIFFERENCE BETWEEN INTERNAL FRAME AND MAIN FRAME:-

Internal frames are not windows or top level container because we add them into a main window.They are also different because we can   iconify or maximize internal frame by making changes in code.

IMPORTANT POINTS REGARDING INTERNAL FRAMES:-


Make it visible using setVisible() method.
If we donot set the size of internal frames it will unvisible it can be done using setSize().
Then set the location of intetnal frame regarding to the main frame.
In last add it into a main frame.

Its general constructor is 
JInternalFrame(String tittle,boolean closable,boolen resizable,boolean iconify)


CODING:

import javax.swing.*;
import java.awt.*;
class myjframe1 extends JFrame
{

public myjframe1() 
{

setTitle("Internal Frames");
setDefaultCloseOperation(EXIT_ON_CLOSE);      
setSize(700, 500);
setLayout(null);
JInternalFrame in = new JInternalFrame("InternalFrame",true,false,true);
in.setVisible(true);
in.setLocation(90,50);
in.setSize(400,210);
add(in);
JInternalFrame in1 = new JInternalFrame("InternalFrame 1",true,true,false);
in1.setVisible(true);
in1.setLocation(600,50);
in1.setSize(400,400);
add(in1);
setVisible(true);
}
}
class simpframe
{
public static void main(String args[])
{
myjframe1 x= new myjframe1();
}
}


OUTPUT:



0 comments:

Post a Comment