📄 messagebox.java
字号:
//
// Unified Library Application
// Case study in Unified Modeling Language Toolkit
//
// MessageBox.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.*;
import java.applet.*;
public class MessageBox extends Dialog {
void okButton_Clicked(Event event) {
//{{CONNECTION
dispose();
//}}
}
public MessageBox(Frame parent,String mess) {
super(parent, true);
//{{INIT_CONTROLS
setLayout(null);
addNotify();
resize(insets().left + insets().right + 373,insets().top + insets().bottom + 150);
label1 = new java.awt.Label("A Basic Java Application");
label1.reshape(insets().left + 48,insets().top + 36,324,21);
add(label1);
okButton = new java.awt.Button("OK");
okButton.reshape(insets().left + 156,insets().top + 84,66,27);
add(okButton);
setTitle("Message");
setResizable(false);
//}}
//AudioClip sound = getAudioClip(getCodeBase(),"beep.au");
//sound.play();
label1.setText(mess);
show();
}
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) {
dispose();
return true;
}
if (event.target == okButton && event.id == Event.ACTION_EVENT) {
okButton_Clicked(event);
}
return super.handleEvent(event);
}
//{{DECLARE_CONTROLS
java.awt.Label label1;
java.awt.Button okButton;
//}}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -