Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/cdk/AboutDialog.java


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