KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > web > talk > client > AboutAceOperatorFrame


1 /*
2  * AboutAceOperatorFrame.java
3  *
4  * Created on March 2, 2003, 4:20 AM
5  */

6
7 package com.quikj.application.web.talk.client;
8
9 import java.applet.*;
10 import java.awt.*;
11 import java.awt.event.*;
12 import java.util.*;
13 import java.net.*;
14 import java.io.*;
15 import com.quikj.client.beans.*;
16
17 /**
18  *
19  * @author amit
20  */

21 public class AboutAceOperatorFrame extends java.awt.Frame JavaDoc
22 {
23     
24     /** Creates new form AboutAceOperatorFrame */
25     public AboutAceOperatorFrame(Frame parent, Locale locale, Applet applet)
26     {
27         this.locale = locale;
28         this.applet = applet;
29         initComponents();
30         
31         InputStream istream = AboutAceOperatorFrame.class.getResourceAsStream("quik.jpg");
32         if (istream != null)
33         {
34             ByteArrayOutputStream bos = new ByteArrayOutputStream();
35             
36             byte[] buffer = new byte[1000];
37             
38             try
39             {
40                 while (true)
41                 {
42                     int count = istream.read(buffer);
43                     if (count == -1) // EOF
44
{
45                         break;
46                     }
47                     
48                     bos.write(buffer, 0, count);
49                 }
50                 
51                 image = Toolkit.getDefaultToolkit().createImage(bos.toByteArray());
52                 ImageButton i_button = new ImageButton();
53                 i_button.setImage(image);
54                 
55                 i_button.addActionListener(new AboutAceOperatorFrame.ButtonClickedActionListener());
56                 imagePane.add(i_button);
57                 i_button.invalidate();
58                 
59             }
60             catch (IOException ex)
61             {
62                 imagePane.setBackground(Color.white);
63             }
64         }
65         else
66         {
67             imagePane.setBackground(Color.white);
68         }
69         
70         // does not work with old version of Netscape/IE - crap!
71
// URL quik_logo = AboutAceOperatorFrame.class.getResource("quik.jpg");
72
// if (quik_logo != null)
73
// {
74
// image = Toolkit.getDefaultToolkit().getImage(quik_logo);
75
//
76
// ImageButton i_button = new ImageButton();
77
// i_button.setImage(image);
78
//
79
// i_button.addActionListener(new AboutAceOperatorFrame.ButtonClickedActionListener());
80
// imagePane.add(i_button);
81
// i_button.invalidate();
82
// }
83
// else
84
// {
85
// imagePane.setBackground(Color.white);
86
// }
87

88         // and center it
89
if (parent == null)
90         {
91             Dimension pbounds = Toolkit.getDefaultToolkit().getScreenSize();
92             Point mid = new Point(pbounds.width/2, pbounds.height/2);
93             Rectangle bounds = getBounds();
94             int x = mid.x - (bounds.width/2);
95             int y = mid.y - (bounds.height/2);
96             if (x < 0) x = 0;
97             if (y < 0) y = 0;
98             setBounds(x, y, bounds.width, bounds.height);
99         }
100         else
101         {
102             Rectangle pbounds = parent.getBounds();
103             Point mid = new Point(pbounds.x + (pbounds.width/2), pbounds.y + (pbounds.height/2));
104             Rectangle bounds = getBounds();
105             int x = mid.x - (bounds.width/2);
106             int y = mid.y - (bounds.height/2);
107             if (x < 0) x = pbounds.x;
108             if (y < 0) y = pbounds.y;
109             setBounds(x, y, bounds.width, bounds.height);
110         }
111         
112         show();
113         
114     }
115     
116     /** This method is called from within the constructor to
117      * initialize the form.
118      * WARNING: Do NOT modify this code. The content of this method is
119      * always regenerated by the Form Editor.
120      */

121     private void initComponents()//GEN-BEGIN:initComponents
122
{
123         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
124
125         panel2 = new java.awt.Panel JavaDoc();
126         imagePane = new ScrollPane(ScrollPane.SCROLLBARS_NEVER);
127         imagePane.setSize(175, 100);
128         label1 = new java.awt.Label JavaDoc();
129         panel1 = new java.awt.Panel JavaDoc();
130         button1 = new java.awt.Button JavaDoc();
131
132         setLayout(new java.awt.GridBagLayout JavaDoc());
133
134         setBackground(java.awt.Color.white);
135         setTitle(java.util.ResourceBundle.getBundle("com.quikj.application.web.talk.client.language", locale).getString("Powered_by"));
136         addWindowListener(new java.awt.event.WindowAdapter JavaDoc()
137         {
138             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt)
139             {
140                 exitForm(evt);
141             }
142         });
143
144         panel2.setLayout(new java.awt.GridBagLayout JavaDoc());
145
146         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
147         gridBagConstraints.gridx = 0;
148         gridBagConstraints.gridy = 0;
149         panel2.add(imagePane, gridBagConstraints);
150
151         label1.setFont(new java.awt.Font JavaDoc("Dialog", 1, 12));
152         label1.setText(java.util.ResourceBundle.getBundle("com.quikj.application.web.talk.client.language", locale).getString("Ace_Operator_is_powered_by_QUIK_Computing_http_www_quik-j_com"));
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 1;
155         gridBagConstraints.gridy = 0;
156         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
157         gridBagConstraints.weightx = 100.0;
158         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 5, 0, 0);
159         panel2.add(label1, gridBagConstraints);
160
161         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
162         gridBagConstraints.gridx = 0;
163         gridBagConstraints.gridy = 0;
164         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
165         gridBagConstraints.weightx = 100.0;
166         gridBagConstraints.weighty = 100.0;
167         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 10, 10);
168         add(panel2, gridBagConstraints);
169
170         panel1.setLayout(new java.awt.GridBagLayout JavaDoc());
171
172         button1.setLabel(java.util.ResourceBundle.getBundle("com.quikj.application.web.talk.client.language", locale).getString("_Close_"));
173         button1.addActionListener(new java.awt.event.ActionListener JavaDoc()
174         {
175             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
176             {
177                 button1ActionPerformed(evt);
178             }
179         });
180
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
182         gridBagConstraints.gridx = 0;
183         gridBagConstraints.gridy = 0;
184         panel1.add(button1, gridBagConstraints);
185
186         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
187         gridBagConstraints.gridx = 0;
188         gridBagConstraints.gridy = 1;
189         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
191         gridBagConstraints.weightx = 100.0;
192         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 10, 10, 10);
193         add(panel1, gridBagConstraints);
194
195         pack();
196     }//GEN-END:initComponents
197

198     private void button1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_button1ActionPerformed
199
{//GEN-HEADEREND:event_button1ActionPerformed
200
// Add your handling code here:
201
dispose();
202     }//GEN-LAST:event_button1ActionPerformed
203

204     /** Exit the Application */
205     private void exitForm(java.awt.event.WindowEvent JavaDoc evt)
206     {//GEN-FIRST:event_exitForm
207
dispose();
208     }//GEN-LAST:event_exitForm
209

210     /**
211      * @param args the command line arguments
212      */

213     public static void main(String JavaDoc args[])
214     {
215         new AboutAceOperatorFrame(null, Locale.getDefault(), null).show();
216     }
217     
218     class ButtonClickedActionListener implements ActionListener
219     {
220         public void actionPerformed(java.awt.event.ActionEvent JavaDoc actionEvent)
221         {
222             handleButtonClick();
223         }
224     }
225     
226     private void handleButtonClick()
227     {
228         if (applet != null)
229         {
230             try
231             {
232                 applet.getAppletContext().showDocument(new URL("http://www.quik-computing.com"),
233                 "_blank");
234             }
235             catch (MalformedURLException ex)
236             {
237                 ;
238             }
239         }
240     }
241     
242     
243     // Variables declaration - do not modify//GEN-BEGIN:variables
244
private java.awt.Label JavaDoc label1;
245     private java.awt.ScrollPane JavaDoc imagePane;
246     private java.awt.Panel JavaDoc panel2;
247     private java.awt.Panel JavaDoc panel1;
248     private java.awt.Button JavaDoc button1;
249     // End of variables declaration//GEN-END:variables
250

251     private Locale locale;
252     private Image image;
253     private Applet applet = null;
254 }
255
Popular Tags