confirm.java

来自「Single-layer neural networks can be trai」· Java 代码 · 共 79 行

JAVA
79
字号
//import java.applet.*;import java.awt.*;import java.awt.event.*;// Changed by Sebastien Baehni in order to be// deprecated compliant.public class Confirm extends Dialog {        /**	 * 	 */	private static final long serialVersionUID = 1L;	//don't know what this is good for, but seems like making eclipse happy		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");	// Addition of an actionlistener	ActionListener okListener = new ActionListener() {	    public void actionPerformed(ActionEvent e) {		okPerformed();	    }	};	ok.addActionListener(okListener);	cancel = new Button("Cancel");	// Addition of an actionlistener	ActionListener cancelListener = new ActionListener() {	    public void actionPerformed(ActionEvent e) {		cancelPerformed();	    }	};	cancel.addActionListener(cancelListener);	buttonPanel.add(ok);	buttonPanel.add(cancel);	add("Center",textPanel);	add("South",buttonPanel);	setSize(200,128);	answer = CANCEL;	this.enableEvents(AWTEvent.WINDOW_EVENT_MASK);	// We put the dialog in the center of the screen.	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();	this.setLocation(Math.abs((dimension.width-this.getSize().width)/2),Math.abs((dimension.height-this.getSize().height)/2));    }        public void okPerformed() {	answer = OK;	this.dispose();    }        public void cancelPerformed() {	this.dispose();    }        // We change the handleEvent to a processWindowEvent.    protected void processWindowEvent(WindowEvent e) {		if (e.getID() == WindowEvent.WINDOW_CLOSING) {	 	    this.dispose();	    	    super.processWindowEvent(e);	}    }     }

⌨️ 快捷键说明

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