home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt.util.dialog;
-
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Dialog;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.Rectangle;
- import java.awt.Window;
-
- public strictfp class DialogBox extends Dialog {
- protected Button okButton;
-
- public DialogBox(Frame f) {
- this(f, false);
- }
-
- public DialogBox(Frame f, boolean modal) {
- this(f, "", modal);
- }
-
- public DialogBox(Frame f, String s, boolean modal) {
- super(f, s, modal);
- ((Dialog)this).setResizable(false);
- }
-
- public synchronized void show() {
- Rectangle bounds = ((Component)this).getParent().bounds();
- Rectangle abounds = ((Component)this).bounds();
- ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
- super.show();
- }
-
- protected void closeDialog() {
- ((Component)this).hide();
- ((Window)this).dispose();
- }
-
- public boolean handleEvent(Event event) {
- if (event.target == this.okButton && event.id == 1001 || event.target == this && event.id == 201) {
- this.closeDialog();
- }
-
- return super.handleEvent(event);
- }
- }
-