⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 confirmdialog.java

📁 JaNet: Java Neural Network Toolkit resume: A well documented toolkit for designing and training, a
💻 JAVA
字号:
////////////////////////////////////////////////////////////////////////////////////  //  //  Copyright (C) 1996 L.  Patocchi & W.Gander////  This program is free  software;  you can  redistribute  it and/or  modify it//  under the terms of the GNU General  Public  License as published by the Free//  Software  Foundation;  either  version 2 of the License, or (at your option)//  any later version.////  This program is  distributed in the hope that it will be useful, but WITHOUT//  ANY  WARRANTY;  without  even the implied  warranty  of  MERCHANTABILITY  or//  FITNESS FOR A PARTICULAR  PURPOSE.  See the GNU General  Public  License for//  more details.////  You should have received a copy of the GNU General Public License along with//  this program; if not, write to the Free Software  Foundation, Inc., 675 Mass//  Ave, Cambridge, MA 02139, USA.////  Contacts://  //    Project Supervisor//      W.Hett       hew@info.isbiel.ch//  //    Authors//      W.Gander     gandw@info.isbiel.ch//      L.Patocchi   patol@info.isbiel.ch////  Documentation can be found at:////      http://www.isbiel.ch/Projects/janet/index.html////////////////////////////////////////////////////////////////////////////////////////// File : confirmDialog.java//package jaNet; import java.awt.*;public class confirmDialog extends Dialog {			public Label 			labelMessage;	public Button 			buttonOk;	public Button 			buttonCancel;    private Confirmable		dearParent;    private int				ID;	public confirmDialog(Frame parent, String message, int id) {		super(parent, " ", false);		Separator separator1;		Separator separator2;		// setup the identificator		ID = id;		// this is my parent		dearParent = (Confirmable) parent;        this.setBackground(Color.lightGray);		// main panel		GridBagLayout grid = new GridBagLayout();		int rowHeights[] = {0,10,9,25,10,30,5};		int columnWidths[] = {0,5,50,75,50,75,50,5};		double rowWeights[] = {0.0,0.0,0.0,1.0,0.0,0.0,0.0};		double columnWeights[] = {0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0};		grid.rowHeights = rowHeights;		grid.columnWidths = columnWidths;		grid.rowWeights = rowWeights;		grid.columnWeights = columnWeights;		separator1 = new Separator(Separator.HORIZONTAL);    	separator1.perSide = 0;    	separator1.rise = Separator.IN;		this.add(separator1);		labelMessage = new Label();		labelMessage.setFont(new Font("Helvetica",Font.BOLD , 14));		labelMessage.setText(message);		this.add(labelMessage);		separator2 = new Separator(Separator.HORIZONTAL);    	separator2.perSide = 0;    	separator2.rise = Separator.IN;		this.add(separator2);		buttonOk = new Button();		buttonOk.setLabel("OK");		this.add(buttonOk);		buttonCancel = new Button();		buttonCancel.setLabel("Cancel");		this.add(buttonCancel);		// Geometry management		GridBagConstraints con = new GridBagConstraints();		reset(con);		con.gridx = 1;		con.gridy = 2;		con.gridwidth = 7;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.BOTH;		grid.setConstraints(separator1, con);		reset(con);		con.gridx = 2;		con.gridy = 3;		con.gridwidth = 5;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.NONE;		grid.setConstraints(labelMessage, con);		reset(con);		con.gridx = 1;		con.gridy = 4;		con.gridwidth = 7;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.BOTH;		grid.setConstraints(separator2, con);		reset(con);		con.gridx = 3;		con.gridy = 5;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(buttonOk, con);		reset(con);		con.gridx = 5;		con.gridy = 5;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(buttonCancel, con);		// Resize behavior management and parent heirarchy		setLayout(grid);        addNotify();        pack();	}	    public synchronized void show(String message) {		labelMessage.setText(message);		resize(preferredSize());		show();	}    public synchronized void show() {		Rectangle bounds = getParent().bounds();		Rectangle abounds = bounds();		move(bounds.x + (bounds.width - abounds.width)/ 2,		     (bounds.height + abounds.height));				pack();		super.show();    }	private void reset(GridBagConstraints con) {		con.gridx = GridBagConstraints.RELATIVE;		con.gridy = GridBagConstraints.RELATIVE;		con.gridwidth = 1;		con.gridheight = 1;		con.weightx = 0;		con.weighty = 0;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.NONE;		con.insets = new Insets(0, 0, 0, 0);		con.ipadx = 0;		con.ipady = 0;	}	    public boolean handleEvent(Event event) {    	if (event.id == Event.ACTION_EVENT && event.target == buttonOk) {			dearParent.confirmIsYes(ID);			hide();			dispose();			return true;    	}else    	if (event.id == Event.ACTION_EVENT && event.target == buttonCancel) {			dearParent.confirmIsNo(ID);			hide();			dispose();			return true;    	}else    	if (event.id == Event.WINDOW_DESTROY) {    	    dearParent.confirmIsNo(ID);    	    hide();    	    dispose();    	    return true;    	}    	return super.handleEvent(event);    }}

⌨️ 快捷键说明

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