• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To create MDI....

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic