aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How To create MDI...." Watch "How To create MDI...." New topic
Author

How To create MDI....

Anthony Levis
Greenhorn

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

WindowUtilities.setNativeLookAndFeel();
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");
WindowUtilities.setNativeLookAndFeel();
addWindowListener(new ExitListener());
Container content = getContentPane();
content.setBackground(Color.white);

JDesktopPane desktop=new JDesktopPane();
desktop.setBackground(Color.white);
content.add(desktop, BorderLayout.CENTER);
setSize(450,400);
for(int i=0;i<5;i++){
JInternalFrame frame=new JInternalFrame(("Internal Frame " + i),true,true,true,true);
frame.setLocation(i*50+10,i*50+10);
frame.setBackground(Color.white);
frame.setSize(200,150);
frame.setVisible(true);
frame.moveToFront();
}
setVisible(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, www.gsi3d.org.uk
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.

eg:-
public static void main(String [] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
new JInternalFrames();
}

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


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

All The Best.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To create MDI....
 
Similar Threads
Something like MDI forms in Java
JInternalFrames + JSliders
create MDI
Internal Frames Problems...need help
Adding Buttons in JDesktoPane