home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-06 | 1.7 KB | 69 lines |
- /*
- A basic extension of the java.awt.Dialog class
- */
-
- import java.awt.*;
-
- public class QuitDialog extends Dialog {
- void yesButton_Clicked(Event event) {
- getParent().handleEvent(new Event(this, Event.WINDOW_DESTROY, null));
- }
-
- void noButton_Clicked(Event event) {
- hide();
- }
-
-
- public QuitDialog(Frame parent, boolean modal) {
-
- super(parent, modal);
-
- //{{INIT_CONTROLS
- setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
- addNotify();
- resize(insets().left + insets().right + 295,insets().top + insets().bottom + 92);
- yesButton = new java.awt.Button("Yes");
- yesButton.reshape(insets().left + 51,insets().top + 20,60,40);
- add(yesButton);
- noButton = new java.awt.Button("No");
- noButton.reshape(insets().left + 165,insets().top + 20,60,40);
- add(noButton);
- setResizable(false);
- //}}
- }
-
- public QuitDialog(Frame parent, String title, boolean modal) {
- this(parent, modal);
- setTitle(title);
- }
-
- public synchronized void show() {
- Rectangle bounds = getParent().bounds();
- Rectangle abounds = bounds();
-
- move(bounds.x + (bounds.width - abounds.width)/ 2,
- bounds.y + (bounds.height - abounds.height)/2);
-
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if(event.id == Event.WINDOW_DESTROY) {
- hide();
- return true;
- }
- if (event.target == noButton && event.id == Event.ACTION_EVENT) {
- noButton_Clicked(event);
- }
- if (event.target == yesButton && event.id == Event.ACTION_EVENT) {
- yesButton_Clicked(event);
- }
- return super.handleEvent(event);
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Button yesButton;
- java.awt.Button noButton;
- //}}
- }
-