📄 yncdialog.java
字号:
package ergo.ui;
// $Id: YNCDialog.java,v 1.2 1999/08/13 01:20:11 sigue Exp $
/*
* Copyright (C) 1999 Carl L. Gay and Antranig M. Basman.
* See the file copyright.txt, distributed with this software,
* for further information.
*/
import java.awt.*;
import java.awt.event.*;
// Yes/No/Cancel dialog
public class YNCDialog extends ErgoDialog implements ActionListener {
private Button yesButton = null;
private Button noButton = null;
private Button cancelButton = null;
public YNCDialog (Frame f, String title, boolean modal,
String question, String yes, String no, String cancel,
ActionListener listener) {
super(f, title, modal);
Panel top = new Panel();
Panel bot = new Panel();
top.add(new Label(question));
if (yes != null) {
yesButton = new Button(yes);
yesButton.addActionListener(this);
yesButton.addActionListener(listener);
bot.add(yesButton);
}
if (no != null) {
noButton = new Button(no);
noButton.addActionListener(this);
noButton.addActionListener(listener);
bot.add(noButton);
}
if (cancel != null) {
cancelButton = new Button("Cancel");
cancelButton.addActionListener(this);
cancelButton.addActionListener(listener);
bot.add(cancelButton);
}
add("North", top);
add("South", bot);
}
public YNCDialog (Frame f, String title, boolean modal, String question,
ActionListener listener, boolean cancelp) {
this(f, title, modal, question, "Yes", "No",
(cancelp ? "Cancel" : null), listener);
}
// Any button closes the dialog.
public void actionPerformed (ActionEvent e) {
close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -