📄 confirm.java
字号:
import java.applet.*;import java.awt.*;import java.awt.event.*;class Confirm extends Dialog implements WindowListener { Button ok; Button cancel; Panel buttonPanel; Panel textPanel; final static public int OK=1; final static public int CANCEL=2; public static int answer; public Confirm(Frame frame, boolean mode,String text) { super(frame,mode); setTitle("Confirm"); textPanel = new Panel(); textPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); textPanel.add(new Label(text)); buttonPanel = new Panel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); ok = new Button("Ok"); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { answer = OK; dispose(); } }; ok.addActionListener(okListener); cancel = new Button("Cancel"); ActionListener cancelListener = new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }; cancel.addActionListener(cancelListener); buttonPanel.add(ok); buttonPanel.add(cancel); add("Center",textPanel); add("South",buttonPanel); setSize(200,128); answer = CANCEL; this.addWindowListener(this); } public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { dispose(); } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -