File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes How To create MDI.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How To create MDI...." Watch "How To create MDI...." New topic

How To create MDI....

Anthony Levis

Joined: Dec 15, 2004
Posts: 10
The program below is example coding for create a MDI...
but i duno y the source code cannot run properly...

it show me that cannot find symbol variable WindowUtilities
and cannot find symbol class ExitListener

is it this 2 coding got any problem

addWindowListener(new ExitListener());

can anyone tell me how to correct it...

if anyone got the example about creating MDI please show me also...
thank you......

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class JInternalFrames extends JFrame{
public static void main(String [] args){
new JInternalFrames();


public JInternalFrames(){
super("Multiple Document Interface");
addWindowListener(new ExitListener());
Container content = getContentPane();

JDesktopPane desktop=new JDesktopPane();
content.add(desktop, BorderLayout.CENTER);
for(int i=0;i<5;i++){
JInternalFrame frame=new JInternalFrame(("Internal Frame " + i),true,true,true,true);
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
Have you got the Classes WindowsUtilities and ExitListener on you system and does your classpath point to them? These two classes are not part of core java.
Have you read the tutorial from Sun ?
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Here is a slight variation on example I got from the web..

The problems you were having basically related to thos etwo lines because they were referencing classes which you obviously don't have, or at least that aren't in the right place. WindowUtilities, for example, is not core Java. Did you get this as an example off a web site...maybe you need to download some other classes from there if you want to run the example as-is. Looks like Marty Halls's tutorial???

SCJP 1.4,
sasi kala
Ranch Hand

Joined: Dec 17, 2004
Posts: 68
Hi Anthony Levis ,

Your code need some changes.

1) addWindowListener(new ExitListener());
In this line ExitListener is a user defined class, if you don't
have that use setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

i.e., remove addWindowListener(new ExitListener()); and
place setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

2) WindowUtilities.setNativeLookAndFeel();
This is used to set window look and feel.
Instead of that place
JFrame.setDefaultLookAndFeelDecorated(true); in main method.

public static void main(String [] args)
new JInternalFrames();

3) Another point is add this below line at the end of "for loop".

Then your code will work. Hope this will help you.

All The Best.
subject: How To create MDI....
It's not a secret anymore!