Internal Frame in Core Java

While doing my college project i find this example to be very useful to use internal frame as MDI child. It is a simple example where internal frame is made visible and invisible to make MDI possible.

//File Name JIFDemo.Java
/**
 *
 * @author prashant-lappy
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class JIFDemo extends JFrame{

 public static void main(String [] args){
 new JIFDemo();
 }

 public JIFDemo()
 {
 // Create an internal frame
 boolean resizable = true;
 boolean closeable = true;
 boolean maximizable  = true;
 boolean iconifiable = true;
 String title = "Frame Title";
 JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable);

 // Set an initial size
 int width = 200;
 int height = 50;
 iframe.setSize(width, height);

 // By default, internal frames are not visible; make it visible
 iframe.setVisible(true);

 // Add components to internal frame...
 iframe.getContentPane().add(new JTextArea("Hello"));

 // Add internal frame to desktop
 JDesktopPane desktop = new JDesktopPane();
 desktop.add(iframe);

 // Display the desktop in a top-level frame
 getContentPane().add(desktop, BorderLayout.CENTER);
 setBounds(100, 100, 300, 300);
 setVisible(true);

 }
}

Advertisements

2 Responses to Internal Frame in Core Java

  1. papFarFMimI says:

    Unadulterated words, some true words dude. Thanx for making my day!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: