home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / handson / java / vectors2 / aboutdialog.java < prev    next >
Encoding:
Java Source  |  1997-02-06  |  1.5 KB  |  62 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class AboutDialog extends Dialog {
  8.     void doneButton_Clicked(Event event) {
  9.         hide();
  10.     }
  11.  
  12.  
  13.     public AboutDialog(Frame parent, boolean modal) {
  14.  
  15.         super(parent, modal);
  16.  
  17.         //{{INIT_CONTROLS
  18.         setLayout(null);
  19.         addNotify();
  20.         resize(insets().left + insets().right + 327,insets().top + insets().bottom + 91);
  21.         label1 = new java.awt.Label("A basic Java application");
  22.         label1.reshape(insets().left + 26,insets().top + 33,181,19);
  23.         add(label1);
  24.         doneButton = new java.awt.Button("Done");
  25.         doneButton.reshape(insets().left + 233,insets().top + 16,60,40);
  26.         add(doneButton);
  27.         setResizable(false);
  28.         //}}
  29.     }
  30.  
  31.     public AboutDialog(Frame parent, String title, boolean modal) {
  32.         this(parent, modal);
  33.         setTitle(title);
  34.     }
  35.  
  36.     public synchronized void show() {
  37.         Rectangle bounds = getParent().bounds();
  38.         Rectangle abounds = bounds();
  39.  
  40.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  41.              bounds.y + (bounds.height - abounds.height)/2);
  42.  
  43.         super.show();
  44.     }
  45.  
  46.     public boolean handleEvent(Event event) {
  47.         if(event.id == Event.WINDOW_DESTROY) {
  48.             hide();
  49.             return true;
  50.         }
  51.         if (event.target == doneButton && event.id == Event.ACTION_EVENT) {
  52.             doneButton_Clicked(event);
  53.         }
  54.         return super.handleEvent(event);
  55.     }
  56.  
  57.     //{{DECLARE_CONTROLS
  58.     java.awt.Label label1;
  59.     java.awt.Button doneButton;
  60.     //}}
  61. }
  62.