home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.WindowEvent;
-
- public class QuitDialog extends Dialog {
- boolean fComponentsAdjusted;
- Button yesButton;
- Button noButton;
- Label label1;
-
- void QuitDialog_WindowClosing(WindowEvent event) {
- ((Component)this).hide();
- }
-
- void yesButton_Clicked(ActionEvent event) {
- Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent((java.awt.Window)((Component)this).getParent(), 201));
- }
-
- void noButton_Clicked(ActionEvent event) {
- ((Component)this).hide();
- }
-
- public QuitDialog(Frame parent, boolean modal) {
- super(parent, modal);
- this.fComponentsAdjusted = false;
- ((Container)this).setLayout((LayoutManager)null);
- ((Component)this).setVisible(false);
- ((Component)this).setSize(((Container)this).insets().left + ((Container)this).insets().right + 337, ((Container)this).insets().top + ((Container)this).insets().bottom + 135);
- ((Component)this).setFont(new Font("Dialog", 0, 12));
- ((Component)this).setForeground(new Color(0));
- ((Component)this).setBackground(new Color(16777215));
- this.yesButton = new Button();
- this.yesButton.setLabel(" Yes ");
- this.yesButton.setBounds(((Container)this).insets().left + 72, ((Container)this).insets().top + 80, 79, 22);
- this.yesButton.setFont(new Font("Dialog", 1, 12));
- ((Container)this).add(this.yesButton);
- this.noButton = new Button();
- this.noButton.setLabel(" No ");
- this.noButton.setBounds(((Container)this).insets().left + 185, ((Container)this).insets().top + 80, 79, 22);
- this.noButton.setFont(new Font("Dialog", 1, 12));
- ((Container)this).add(this.noButton);
- this.label1 = new Label("Do you really want to quit?", 1);
- this.label1.setBounds(((Container)this).insets().left + 78, ((Container)this).insets().top + 33, 180, 23);
- ((Container)this).add(this.label1);
- ((Dialog)this).setTitle("A Basic Application - Quit");
- QuitDialog$Window lWindow = new QuitDialog$Window(this);
- ((java.awt.Window)this).addWindowListener(lWindow);
- QuitDialog$Action lAction = new QuitDialog$Action(this);
- this.noButton.addActionListener(lAction);
- this.yesButton.addActionListener(lAction);
- }
-
- public void addNotify() {
- super.addNotify();
- if (!this.fComponentsAdjusted) {
- ((Component)this).setSize(((Container)this).insets().left + ((Container)this).insets().right + ((Component)this).getSize().width, ((Container)this).insets().top + ((Container)this).insets().bottom + ((Component)this).getSize().height);
- Component[] components = ((Container)this).getComponents();
-
- for(int i = 0; i < components.length; ++i) {
- Point p = components[i].getLocation();
- p.translate(((Container)this).insets().left, ((Container)this).insets().top);
- components[i].setLocation(p);
- }
-
- this.fComponentsAdjusted = true;
- }
- }
-
- public QuitDialog(Frame parent, String title, boolean modal) {
- this(parent, modal);
- ((Dialog)this).setTitle(title);
- }
-
- 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();
- }
- }
-