Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Create a Desktop Pane Container in Java 
 

In this section, you will learn how to create a desktop pane container in Java.

 

Create a Desktop Pane Container in Java

                         

In this section, you will learn how to create a desktop pane container in Java. The desktop pane container is a container, which has the internal frame. This internal frame has the same feature as like a frame. The desktop pane is like a MDI (Multiple Document Interface) frame and all internal frames are like the child frame for the main frame. All internal frames open under the desktop pane. Following figure shows the JDesktopPane component of Java Swing:

Swing JDesktopPane component with a child frame

This program shows the internal frame inside the MDI frame. The internal frame has two command buttons: Ok and Cancel. This frame has the minimize, maximize and close buttons that provides the minimize (iconify), maximize and the close operations. Buttons on the internal frame have the tool tip text. Following methods and APIs have been used in the given program for getting the desktop pane container:

JInternalFrame(String iframe_title, Boolean resizable, Boolean closable, Boolean maximizable, Boolean minimizable ):

JInternalFrame():
This is the constructor of JInternalFrame class. It extends from the JComponent. This constructor has been used to create a new internal frame. This constructor takes some argument as follow:

  • First is the title of the internal frame which has to be shown in the desktop pane.
  • Second is the boolean value either true or false which determines the frame should be resizable or not.
  • Third is also a boolean value true or false which determines the frame should be closable or not.
  • Fourth is also a boolean value true or false which determines the frame should be maximize or not.
  • And last is also a boolean value which determines for the iconifying.

JDesktopPane:
This is the class which creates a desktop pane like MDI (Multiple Document Interface).

Here is the code of program:

import javax.swing.*;

public class DesktopContainer{
  JFrame frame;
  JPanel panel;
  JInternalFrame iframe;
  JButton button1, button2;
  JDesktopPane desk;
  public static void main(String[] args) {
    DesktopContainer d = new DesktopContainer();
  }
  public DesktopContainer(){
    frame = new JFrame("Creating a JDesktopPane Container");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    iframe = new JInternalFrame("Internal frame", true,true,true,true);
    iframe.setToolTipText("This is internal frame");
    panel = new JPanel();
    button1 = new JButton("Ok");
    button1.setToolTipText("This is Ok button of internal frame");
    panel.add(button1);
    button2 = new JButton("Cancel");
    button2.setToolTipText("This is cancel button of internal frame");
    panel.add(button2);
    iframe.add(panel);
    iframe.setSize(250,300);
    iframe.setVisible(true);
    desk = new JDesktopPane();
    desk.add(iframe);
    frame.add(desk);
    frame.setSize(400,400);
    frame.setVisible(true);
  }
}

Download this example

                         

» View all related tutorials
Related Tags: c string class text mono rendering method 2d get type font display return context int ai render center define if

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Its nice .....
And it was much more help full for me....

Posted by biren kumar swain on Tuesday, 05.20.08 @ 19:00pm | #60523

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.