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

📄 confirmdialog.java

📁 Java程序设计技巧与开发实例附书源代码。
💻 JAVA
字号:
import java.awt.*;import java.awt.event.*;public class ConfirmDialog extends Dialog implements ActionListener{  private Button okay = new Button("确定");   private Button cancel = new Button("取消");   private Label  label = new Label("Are you sure?",Label.CENTER);   public  boolean isOkay = false;   private class WindowCloser extends WindowAdapter   {  public void windowClosing(WindowEvent we)      {  ConfirmDialog.this.isOkay = false;         ConfirmDialog.this.hide();      }   }   public ConfirmDialog(Frame parent)   {  this(parent,"Please confirm","Are you sure?"); }   public ConfirmDialog(Frame parent,String title,String question)   {  super(parent,title,true);      label.setText(question);      setup();      okay.addActionListener(this);      cancel.addActionListener(this);      addWindowListener(new WindowCloser());      setResizable(false);      pack(); show();   }   private void setup()   {  Panel buttons = new Panel();      buttons.setLayout(new FlowLayout());      buttons.add(okay); buttons.add(cancel);      setLayout(new BorderLayout());      add("Center",label);  add("South",buttons);   }   public void actionPerformed(ActionEvent ae)   {  isOkay = (ae.getSource() == okay);      hide();   }}

⌨️ 快捷键说明

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