8 package org.bitstorm.util;
10 import java.awt.AWTEvent;
11 import java.awt.Button;
12 import java.awt.Dialog;
13 import java.awt.Dimension;
14 import java.awt.Event;
15 import java.awt.FlowLayout;
16 import java.awt.Frame;
17 import java.awt.GridLayout;
18 import java.awt.Image;
19 import java.awt.Label;
20 import java.awt.Panel;
21 import java.awt.Point;
22 import java.awt.Toolkit;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.util.StringTokenizer;
45 public AlertBox( Frame parent, String title, String message ) {
46 super( parent, title,
false );
48 Image alertImage = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(
"alert.gif"));
50 okButton =
new Button(
" OK ");
51 okButton.addActionListener(
52 new ActionListener() {
53 public void actionPerformed(ActionEvent e) {
58 Panel buttonPanel =
new Panel();
59 buttonPanel.setLayout(
new FlowLayout( FlowLayout.CENTER ) );
60 buttonPanel.add( okButton );
61 StringTokenizer st =
new StringTokenizer( message,
"\n" );
62 Panel messagePanel =
new Panel(
new GridLayout( st.countTokens(), 1 ) );
63 while ( st.hasMoreTokens() ) {
64 messagePanel.add(
new Label( st.nextToken() ) );
66 add(
"West", alertImageComponent );
67 add(
"Center", messagePanel );
68 add(
"South", buttonPanel );
69 enableEvents(Event.WINDOW_DESTROY);
70 setResizable(
false );
73 Point p = parent.getLocation();
74 Dimension dim = parent.getSize();
75 setLocation( p.x+dim.width/2-150, p.y+dim.height/2-75 );
91 if ( e.getID() == Event.WINDOW_DESTROY )
AlertBox(Frame parent, String title, String message)
void processEvent(AWTEvent e)