home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-12-07 | 2.0 KB | 77 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) {
- //{{CONNECTION
- // Clicked from noButton Hide the Dialog
- hide();
- //}}
- }
-
- public QuitDialog(Frame parent, boolean modal) {
-
- super(parent, modal);
-
- //{{INIT_CONTROLS
- setLayout(new FlowLayout(FlowLayout.CENTER,20,35));
- addNotify();
- resize(insets().left + insets().right + 317,insets().top + insets().bottom + 97);
- setFont(new Font("Dialog", Font.BOLD, 12));
- setForeground(new Color(0));
- setBackground(new Color(16777215));
- yesButton = new java.awt.Button(" Yes ");
- yesButton.reshape(insets().left + 112,insets().top + 35,44,21);
- yesButton.setFont(new Font("Dialog", Font.BOLD, 12));
- add(yesButton);
- noButton = new java.awt.Button(" No ");
- noButton.reshape(insets().left + 161,insets().top + 35,39,21);
- noButton.setFont(new Font("Dialog", Font.BOLD, 12));
- add(noButton);
- setTitle("Really Quit?");
- 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;
- //}}
- }
-