home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / WDESAMPL.BIN / AboutDialog.java < prev    next >
Text File  |  1998-02-26  |  4KB  |  134 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6. import java.io.*;
  7.  
  8. import symantec.itools.awt.WrappingLabel;
  9. public class AboutDialog extends Dialog {
  10.     private final String aboutTxtFile = "EmployeeDataManager.txt";
  11.     void AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
  12.         dispose();
  13.     }
  14.  
  15.     void okButton_Clicked(java.awt.event.ActionEvent event) {
  16.         //{{CONNECTION
  17.         // Clicked from okButton dispose the Dialog
  18.         dispose();
  19.         //}}
  20.     }
  21.  
  22.     public AboutDialog(Frame parent, boolean modal) {
  23.         super(parent, modal);
  24.  
  25.         // This code is automatically generated by Visual Cafe when you add
  26.         // components to the visual environment. It instantiates and initializes
  27.         // the components. To modify the code, only use code syntax that matches
  28.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  29.         // parse your Java file into its visual environment.
  30.  
  31.         //{{INIT_CONTROLS
  32.         setLayout(new BorderLayout(0,0));
  33.         setVisible(false);
  34.         setSize(527,320);
  35.         setBackground(new Color(12632256));
  36.         panel1 = new java.awt.Panel();
  37.         panel1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  38.         panel1.setBounds(0,287,527,10);
  39.         add("South", panel1);
  40.         okButton = new java.awt.Button();
  41.         okButton.setLabel("OK");
  42.         okButton.setBounds(248,5,31,23);
  43.         panel1.add(okButton);
  44.         textArea1 = new java.awt.TextArea();
  45.         textArea1.setEditable(false);
  46.         textArea1.setBounds(0,0,527,287);
  47.         textArea1.setBackground(new Color(12632256));
  48.         add("Center", textArea1);
  49.         setTitle("About");
  50.         //}}
  51.  
  52.         //{{REGISTER_LISTENERS
  53.         Window lWindow = new Window();
  54.         addWindowListener(lWindow);
  55.         Action lAction = new Action();
  56.         okButton.addActionListener(lAction);
  57.         //}}
  58.         
  59.         try {
  60.             BufferedReader b = new BufferedReader(new InputStreamReader(new FileInputStream(aboutTxtFile)));
  61.             String s = b.readLine();
  62.             while(s!=null) {
  63.                 textArea1.appendText(s+"\n");
  64.                 s = b.readLine();
  65.             }
  66.         } catch (IOException e) {}
  67.             
  68.  
  69.     }
  70.  
  71.     public AboutDialog(Frame parent, String title, boolean modal) {
  72.         this(parent, modal);
  73.         setTitle(title);
  74.     }
  75.  
  76.     public void addNotify()
  77.     {
  78.         super.addNotify();
  79.  
  80.         if (fComponentsAdjusted)
  81.             return;
  82.  
  83.         // Adjust components according to the insets
  84.         setSize(insets().left + insets().right + getSize().width, insets().top + insets().bottom + getSize().height);
  85.         Component components[] = getComponents();
  86.         for (int i = 0; i < components.length; i++)
  87.         {
  88.             Point p = components[i].getLocation();
  89.             p.translate(insets().left, insets().top);
  90.             components[i].setLocation(p);
  91.         }
  92.         fComponentsAdjusted = true;
  93.     }
  94.  
  95.     boolean fComponentsAdjusted = false;
  96.  
  97.     public synchronized void show()
  98.     {
  99.         Rectangle bounds = getParent().bounds();
  100.         Rectangle abounds = bounds();
  101.  
  102.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  103.              bounds.y + (bounds.height - abounds.height)/2);
  104.  
  105.         super.show();
  106.     }
  107.  
  108.     //{{DECLARE_CONTROLS
  109.     java.awt.Panel panel1;
  110.     java.awt.Button okButton;
  111.     java.awt.TextArea textArea1;
  112.     //}}
  113.  
  114.     class Window extends java.awt.event.WindowAdapter
  115.     {
  116.         public void windowClosing(java.awt.event.WindowEvent event)
  117.         {
  118.             Object object = event.getSource();
  119.             if (object == AboutDialog.this)
  120.                 AboutDialog_WindowClosing(event);
  121.         }
  122.     }
  123.  
  124.     class Action implements java.awt.event.ActionListener
  125.     {
  126.         public void actionPerformed(java.awt.event.ActionEvent event)
  127.         {
  128.             Object object = event.getSource();
  129.             if (object == okButton)
  130.                 okButton_Clicked(event);
  131.         }
  132.     }
  133. }
  134.