home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch12 / ui / OutputWindow.java < prev    next >
Text File  |  1997-01-01  |  1KB  |  65 lines

  1. // (c) Justin Couch
  2. //
  3. // From Chapter 13: Late Night VRML 2.0 and Java
  4. //
  5. // The text window that contains the print out of the VRML code
  6. // Consists of a simple menu bar as well as the non editable text area
  7.  
  8. package ui;
  9.  
  10. import java.awt.*;
  11. import java.io.*;
  12. import ui.dialogs.NotImpDialog;
  13.  
  14. public class OutputWindow extends Frame
  15. {
  16.     private NotImpDialog    warn;
  17.     private TextArea    text_area;
  18.  
  19.     public OutputWindow()
  20.     {
  21.         // create warning dialog
  22.         warn = new NotImpDialog(this);
  23.  
  24.         // first create the menubar
  25.         MenuBar menu_bar = new MenuBar();
  26.         Menu file_menu = new Menu("&File", false);
  27.  
  28.         file_menu.add(new MenuItem("&Save"));
  29.         file_menu.addSeparator();
  30.         file_menu.add(new MenuItem("&Close"));
  31.  
  32.         menu_bar.add(file_menu);
  33.         setMenuBar(menu_bar);
  34.  
  35.         // now create the text area that will take the output.
  36.         setLayout(new BorderLayout());
  37.         text_area = new TextArea();
  38.         text_area.setEditable(false);
  39.         add("Center", text_area);
  40.  
  41.         resize(600, 400);
  42.     }
  43.  
  44.     // copy the given string to the Text area. Calls the setText method so
  45.     // it completely replaces the contents that are already there.
  46.     public void setContents(String contents)
  47.     {
  48.         text_area.setText(contents);
  49.     }
  50.  
  51.     public boolean action(Event e, Object arg)
  52.     {
  53.         if(e.target instanceof MenuItem)
  54.         {
  55.             if("&Close".equals(arg))
  56.                 hide();
  57.             else if("&Save".equals(arg))
  58.                 warn.show();
  59.  
  60.             return true;
  61.         }
  62.         return false;
  63.     }
  64. }
  65.