⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quitdialog.java

📁 数据结构及算法 对于参加ACM的学生有一定帮助 里面有详细的解答
💻 JAVA
字号:
//
//  Unified Library Application
//  Case study in Unified Modeling Language Toolkit
//
//  QuitDialog.java
//
//
//  Copyright (c) 1998 John Wiley & Sons, Inc. All rights reserved.
//  Reproduction or translations of this work beyond that permitted
//  in Section 117 of the 1976 United States Copyright Act without
//  the express written permission of the copyright owner is unlawful.
//  Requests for further information should be addressed to Permissions
//  Department, John Wiley & Sons, Inc. The purchaser may make back-up
//  copies for his/her own use only and not for distribution or resale.
//  The Publisher assumes no responsibility for errors, omissions, or
//  damages, caused by the use of these programs of from the use of the
//  information contained herein.

package ui;
import java.awt.*;

public class QuitDialog extends Dialog {
	void yesButton_Clicked(Event event) {
	    System.exit(0);
	}

	void noButton_Clicked(Event event) {
		//{{CONNECTION
		// Clicked from noButton Hide the Dialog
		dispose();
		//}}
	}

	public QuitDialog(Frame parent, boolean modal) {

	    super(parent, modal);

		//{{INIT_CONTROLS
		setLayout(null);
		addNotify();
		resize(insets().left + insets().right + 337,insets().top + insets().bottom + 135);
		yesButton = new java.awt.Button(" Yes ");
		yesButton.reshape(insets().left + 72,insets().top + 84,79,22);
		yesButton.setFont(new Font("Dialog", Font.BOLD, 12));
		add(yesButton);
		noButton = new java.awt.Button("  No  ");
		noButton.reshape(insets().left + 180,insets().top + 84,79,22);
		noButton.setFont(new Font("Dialog", Font.BOLD, 12));
		add(noButton);
		label1 = new java.awt.Label("Do you really want to quit?");
		label1.reshape(insets().left + 84,insets().top + 36,180,23);
		add(label1);
		setTitle("Unified Library Application - 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;
	java.awt.Label label1;
	//}}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -