confirm.java

来自「This applet illustrates the prediction c」· Java 代码 · 共 59 行

JAVA
59
字号
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 + =
减小字号Ctrl + -
显示快捷键?