home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 12 / 12_pcplus_supercd.iso / Pcplus / JAVA / VECTORS / MSGDLG.JAVA next >
Encoding:
Java Source  |  1997-05-08  |  1.4 KB  |  65 lines

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