home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / WDETOUR.BIN / AboutDialog.java < prev    next >
Text File  |  1997-08-29  |  3KB  |  116 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 AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
  9.         dispose();
  10.     }
  11.  
  12.     void okButton_Clicked(java.awt.event.ActionEvent event) {
  13.         //{{CONNECTION
  14.         // Clicked from okButton Hide the Dialog
  15.         dispose();
  16.         //}}
  17.     }
  18.  
  19.     public AboutDialog(Frame parent, boolean modal) {
  20.         super(parent, modal);
  21.  
  22.         // This code is automatically generated by Visual Cafe when you add
  23.         // components to the visual environment. It instantiates and initializes
  24.         // the components. To modify the code, only use code syntax that matches
  25.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  26.         // parse your Java file into its visual environment.
  27.  
  28.         //{{INIT_CONTROLS
  29.         setLayout(null);
  30.         setVisible(false);
  31.         setSize(insets().left + insets().right + 333,insets().top + insets().bottom + 127);
  32.         setFont(new Font("Dialog", Font.PLAIN, 12));
  33.         setForeground(new Color(0));
  34.         setBackground(new Color(16777215));
  35.         label1 = new java.awt.Label("Amazing Adventures Travel - Custom Itinerary Application");
  36.         label1.setBounds(insets().left + 8,insets().top + 37,311,21);
  37.         add(label1);
  38.         okButton = new java.awt.Button();
  39.         okButton.setLabel("OK");
  40.         okButton.setBounds(insets().left + 128,insets().top + 72,66,27);
  41.         add(okButton);
  42.         setTitle("About");
  43.         //}}
  44.  
  45.         //{{REGISTER_LISTENERS
  46.         Window lWindow = new Window();
  47.         addWindowListener(lWindow);
  48.         Action lAction = new Action();
  49.         okButton.addActionListener(lAction);
  50.         //}}
  51.  
  52.     }
  53.  
  54.     public AboutDialog(Frame parent, String title, boolean modal) {
  55.         this(parent, modal);
  56.         setTitle(title);
  57.     }
  58.  
  59.     public void addNotify()
  60.     {
  61.         super.addNotify();
  62.  
  63.         if (fComponentsAdjusted)
  64.             return;
  65.  
  66.         // Adjust components according to the insets
  67.         setSize(insets().left + insets().right + getSize().width, insets().top + insets().bottom + getSize().height);
  68.         Component components[] = getComponents();
  69.         for (int i = 0; i < components.length; i++)
  70.         {
  71.             Point p = components[i].getLocation();
  72.             p.translate(insets().left, insets().top);
  73.             components[i].setLocation(p);
  74.         }
  75.         fComponentsAdjusted = true;
  76.     }
  77.  
  78.     boolean fComponentsAdjusted = false;
  79.  
  80.     public synchronized void show()
  81.     {
  82.         Rectangle bounds = getParent().bounds();
  83.         Rectangle abounds = bounds();
  84.  
  85.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  86.              bounds.y + (bounds.height - abounds.height)/2);
  87.  
  88.         super.show();
  89.     }
  90.  
  91.     //{{DECLARE_CONTROLS
  92.     java.awt.Label label1;
  93.     java.awt.Button okButton;
  94.     //}}
  95.  
  96.     class Window extends java.awt.event.WindowAdapter
  97.     {
  98.         public void windowClosing(java.awt.event.WindowEvent event)
  99.         {
  100.             Object object = event.getSource();
  101.             if (object == AboutDialog.this)
  102.                 AboutDialog_WindowClosing(event);
  103.         }
  104.     }
  105.  
  106.     class Action implements java.awt.event.ActionListener
  107.     {
  108.         public void actionPerformed(java.awt.event.ActionEvent event)
  109.         {
  110.             Object object = event.getSource();
  111.             if (object == okButton)
  112.                 okButton_Clicked(event);
  113.         }
  114.     }
  115. }
  116.