Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 package gui;
00037 
00038 import java.lang.*;    
00039 import java.awt.*;     
00040 import java.io.*;      
00041 import java.awt.event.*;   
00042 
00043 public class WarnDialog extends Dialog
00044 {
00045 
00046   
00047 
00048   public WarnDialog(Frame dw, String text)
00049   {
00050     super(dw, "Info", true);
00051 
00052     Panel p1 = new Panel();
00053     p1.add(new Label(text));
00054 
00055     
00056 
00057     Panel p2 = new Panel();
00058     Button okButton = new Button("Ok");
00059     okButton.addActionListener(new ActionListener()
00060                                { public void actionPerformed(ActionEvent e)
00061                                    { okPressed();}});
00062     p2.add(okButton);
00063 
00064     add("Center",p1);
00065     add("South",p2);
00066 
00067     
00068     pack();
00069     setLocation(defaultLocation());
00070   }
00071 
00072   public Point defaultLocation()
00073   {
00074     Point newLoc;
00075     Toolkit tk = Toolkit.getDefaultToolkit();
00076     Dimension screenSize = tk.getScreenSize();
00077     int w = this.getBounds().width;
00078     int h = this.getBounds().height;
00079     if ((w < screenSize.width) && (h < screenSize.height)) {
00080       newLoc = new Point((screenSize.width-w)/2,
00081                   (screenSize.height-h)/2);
00082     } else {
00083       newLoc = new Point(0,0);
00084     }
00085     return newLoc;
00086   }
00087 
00088   
00089 
00090   public void okPressed()
00091   {
00092     closeDialog();
00093   }
00094 
00095   public void closeDialog()
00096   {
00097     setVisible(false);
00098     dispose();
00099   }
00100 
00101 }
00102