📄 errordialog.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package sports;import java.awt.*;import java.awt.event.*;/** * *该类是弹出的对话框 */class ErrorDialog extends Dialog implements ActionListener{ private Button okay = new Button("确定"); //private Button cancel = new Button("取消"); private Label label = new Label(" ", Label.CENTER); public boolean isOkay = false; @SuppressWarnings("empty-statement") public ErrorDialog(Frame parent, String title, String prompt) { super(parent, title, true); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent Di) { ErrorDialog.this.isOkay = false; ErrorDialog.this.setVisible(false); } }); okay.addActionListener(this); Panel buttons = new Panel(); buttons.setLayout(new FlowLayout()); buttons.add(okay); //buttons.add(cancel); label.setText(prompt); setLayout(new BorderLayout()); add("Center", label); add("South", buttons); pack(); this.setSize(400, 150); this.setLocation(360, 290);; this.setVisible(true); } public void actionPerformed(ActionEvent ae) { isOkay = (ae.getSource() == okay); setVisible(false); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -