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