home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / WDETOUR.BIN / QuitDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-27  |  4.1 KB  |  92 lines

  1. import java.awt.Button;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dialog;
  6. import java.awt.Font;
  7. import java.awt.Frame;
  8. import java.awt.Label;
  9. import java.awt.LayoutManager;
  10. import java.awt.Point;
  11. import java.awt.Rectangle;
  12. import java.awt.Toolkit;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.WindowEvent;
  15.  
  16. public class QuitDialog extends Dialog {
  17.    boolean fComponentsAdjusted;
  18.    Button yesButton;
  19.    Button noButton;
  20.    Label label1;
  21.  
  22.    void QuitDialog_WindowClosing(WindowEvent event) {
  23.       ((Component)this).hide();
  24.    }
  25.  
  26.    void yesButton_Clicked(ActionEvent event) {
  27.       Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent((java.awt.Window)((Component)this).getParent(), 201));
  28.    }
  29.  
  30.    void noButton_Clicked(ActionEvent event) {
  31.       ((Component)this).hide();
  32.    }
  33.  
  34.    public QuitDialog(Frame parent, boolean modal) {
  35.       super(parent, modal);
  36.       this.fComponentsAdjusted = false;
  37.       ((Container)this).setLayout((LayoutManager)null);
  38.       ((Component)this).setVisible(false);
  39.       ((Component)this).setSize(((Container)this).insets().left + ((Container)this).insets().right + 337, ((Container)this).insets().top + ((Container)this).insets().bottom + 135);
  40.       ((Component)this).setFont(new Font("Dialog", 0, 12));
  41.       ((Component)this).setForeground(new Color(0));
  42.       ((Component)this).setBackground(new Color(16777215));
  43.       this.yesButton = new Button();
  44.       this.yesButton.setLabel(" Yes ");
  45.       this.yesButton.setBounds(((Container)this).insets().left + 72, ((Container)this).insets().top + 80, 79, 22);
  46.       this.yesButton.setFont(new Font("Dialog", 1, 12));
  47.       ((Container)this).add(this.yesButton);
  48.       this.noButton = new Button();
  49.       this.noButton.setLabel("  No  ");
  50.       this.noButton.setBounds(((Container)this).insets().left + 185, ((Container)this).insets().top + 80, 79, 22);
  51.       this.noButton.setFont(new Font("Dialog", 1, 12));
  52.       ((Container)this).add(this.noButton);
  53.       this.label1 = new Label("Do you really want to quit?", 1);
  54.       this.label1.setBounds(((Container)this).insets().left + 78, ((Container)this).insets().top + 33, 180, 23);
  55.       ((Container)this).add(this.label1);
  56.       ((Dialog)this).setTitle("A Basic Application - Quit");
  57.       QuitDialog$Window lWindow = new QuitDialog$Window(this);
  58.       ((java.awt.Window)this).addWindowListener(lWindow);
  59.       QuitDialog$Action lAction = new QuitDialog$Action(this);
  60.       this.noButton.addActionListener(lAction);
  61.       this.yesButton.addActionListener(lAction);
  62.    }
  63.  
  64.    public void addNotify() {
  65.       super.addNotify();
  66.       if (!this.fComponentsAdjusted) {
  67.          ((Component)this).setSize(((Container)this).insets().left + ((Container)this).insets().right + ((Component)this).getSize().width, ((Container)this).insets().top + ((Container)this).insets().bottom + ((Component)this).getSize().height);
  68.          Component[] components = ((Container)this).getComponents();
  69.  
  70.          for(int i = 0; i < components.length; ++i) {
  71.             Point p = components[i].getLocation();
  72.             p.translate(((Container)this).insets().left, ((Container)this).insets().top);
  73.             components[i].setLocation(p);
  74.          }
  75.  
  76.          this.fComponentsAdjusted = true;
  77.       }
  78.    }
  79.  
  80.    public QuitDialog(Frame parent, String title, boolean modal) {
  81.       this(parent, modal);
  82.       ((Dialog)this).setTitle(title);
  83.    }
  84.  
  85.    public synchronized void show() {
  86.       Rectangle bounds = ((Component)this).getParent().bounds();
  87.       Rectangle abounds = ((Component)this).bounds();
  88.       ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
  89.       super.show();
  90.    }
  91. }
  92.