WarnDialog.java
Go to the documentation of this file.
00001 /*
00002  * (c) copyright 2008, Technische Universitaet Graz and Technische Universitaet Wien
00003  *
00004  * This file is part of jdiagengine.
00005  *
00006  * jdiagengine is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * jdiagengine is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * You should have received a copy of the GNU General Public License
00016  * along with jdiagengine. If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  * Authors: Joerg Weber, Franz Wotawa
00019  * Contact: jweber@ist.tugraz.at (preferred), or fwotawa@ist.tugraz.at
00020  *
00021  */
00022 
00023 
00024 /*
00025  * WarnDialog: Provides a dialog with one textual field
00026  *
00027  * @version 0.1, DATE: 23.11.1998
00028  * @author Franz Wotawa
00029  *
00030  * This class...
00031  *
00032  * V0.1: Creating the dialog (23.11.1998)
00033  *
00034  */
00035 
00036 package gui;
00037 
00038 import java.lang.*;    // Java language classes 
00039 import java.awt.*;     // User Interface components
00040 import java.io.*;      // IO specific classes (File, Stream,..)
00041 import java.awt.event.*;   // Event handling
00042 
00043 public class WarnDialog extends Dialog
00044 {
00045 
00046   // Instance creation
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     // Create buttons
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     // Initialize this dialog to its preferred size
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   // Action handling
00089 
00090   public void okPressed()
00091   {
00092     closeDialog();
00093   }
00094 
00095   public void closeDialog()
00096   {
00097     setVisible(false);
00098     dispose();
00099   }
00100 
00101 }
00102 


tug_ist_diagnosis_engine
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:16