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

  1. // VRML Generator
  2. // (c) Justin Couch
  3. //
  4. // From Chapter 13: Late Night VRML 2.0 and Java
  5. //
  6. // Not Implemented Yet warning dialog.
  7.  
  8. package ui.dialogs;
  9.  
  10. import java.awt.*;
  11.  
  12. public class GeneralWarnDialog extends Dialog
  13. {
  14.     Button button;
  15.     Label label;
  16.  
  17.     public GeneralWarnDialog(Frame parent)
  18.     {
  19.         super(parent, "Warning", false);
  20.  
  21.         setLayout(new BorderLayout(15, 15));
  22.  
  23.         label = new Label("Warning: ");
  24.         add("Center", label);
  25.  
  26.         // create the OK button in the middle of the dialog
  27.         button = new Button("OK");
  28.         Panel p = new Panel();
  29.  
  30.         p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
  31.         p.add(button);
  32.  
  33.         add("South", p);
  34.  
  35.         // resize to fit
  36.         pack();
  37.     }
  38.  
  39.     public GeneralWarnDialog(Frame parent, String message)
  40.     {
  41.         super(parent, "Warning", false);
  42.  
  43.         setLayout(new BorderLayout(15, 15));
  44.  
  45.         label = new Label(message);
  46.         add("Center", label);
  47.  
  48.         // create the OK button in the middle of the dialog
  49.         button = new Button("OK");
  50.         Panel p = new Panel();
  51.  
  52.         p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
  53.         p.add(button);
  54.  
  55.         add("South", p);
  56.  
  57.         // resize to fit
  58.         pack();
  59.     }
  60.  
  61.     public void show(String message)
  62.     {
  63.         remove(label);
  64.         label = new Label(message);
  65.         add("Center", label);
  66.  
  67.         // resize to fit
  68.         pack();
  69.  
  70.         // now display it
  71.         this.show();
  72.     }
  73.  
  74.     public boolean action(Event e, Object arg)
  75.     {
  76.         if(e.target == button)
  77.         {
  78.             hide();
  79.             return true;
  80.         }
  81.         else
  82.             return false;
  83.     }
  84.  
  85.     public boolean getFocus(Event e, Object arg)
  86.     {
  87.         button.requestFocus();
  88.         return true;
  89.     }
  90. }