📄 alertdialog.java
字号:
// AlertDialog class// ================import java.awt.*;import java.awt.event.*;public class AlertDialog extends Dialog implements WindowListener, ActionListener{ protected Button button; protected Label label; public AlertDialog(Frame parent, String message) { super(parent,"ALERT",false); this.setLayout(new BorderLayout(15,15)); label = new Label(message); this.add("Center",label); button = new Button("Okay"); Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.CENTER,15,15)); p.add(button); button.addActionListener(this); this.add("South",p); this.pack(); this.show(); } public void actionPerformed (ActionEvent event) { if (event.getSource() == button) { this.setVisible(false); this.dispose(); } } // end of method "actionPerformed" public void windowOpened(WindowEvent event) {} public void windowIconified(WindowEvent event) {} public void windowDeiconified(WindowEvent event) {} public void windowClosed(WindowEvent event) {} public void windowActivated(WindowEvent event) {} public void windowDeactivated(WindowEvent event) {} public void windowClosing(WindowEvent event) { dispose(); } // end of method "windowClosing"} // end class "AlertDialog"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -