📄 aboutbox.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 : AboutBox.java///* jaNet - A Neural Network Toolkit for Java ----------------------------------------- Author : W.Gander Modifications : 10.09.1996 Filename : AboutBox.java Description : Shows the About Dialog Box (c) 1996 Biel School of Engineering */package jaNet;import java.awt.*;class AboutBox extends Dialog { public Label label_1; public Label label_2; public Label label_3; public Button OkButton; public GetLogo pic; private int weight, height; public AboutBox(Frame parent, String jaNetHomePath) { super(parent, "About...", false); addNotify(); // main panel GridBagLayout grid = new GridBagLayout(); int rowHeights[] = {0,10,20,10,20,20,10,220,10,30,10}; int columnWidths[] = {0,10,300,10}; double rowWeights[] = {0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0}; double columnWeights[] = {0.0,1.0,0.0,1.0}; grid.rowHeights = rowHeights; grid.columnWidths = columnWidths; grid.rowWeights = rowWeights; grid.columnWeights = columnWeights; for(int i=0;i<rowHeights.length;i++) height += rowHeights[i]; for(int i=0;i<columnWidths.length;i++) weight += columnWidths[i]; resize(insets().left + insets().right+weight, insets().top + insets().bottom + height); this.setBackground(Color.white); label_1 = new Label(); label_1.setFont(new Font("Helvetica",Font.BOLD , 16)); label_1.setText("jaNet - NEURAL NETWORK TOOLKIT"); this.add(label_1); label_2 = new Label(); label_2.setFont(new Font("Helvetica",Font.PLAIN , 12)); label_2.setText("Written by L.Patocchi and W.Gander"); this.add(label_2); label_3 = new Label(); label_3.setFont(new Font("Helvetica",Font.PLAIN , 12)); label_3.setText("(c) 1996 Biel School of Engineering"); this.add(label_3); // Add the picture pic = new GetLogo(jaNetHomePath); add (pic); // Add the OK button OkButton = new Button(); OkButton.setLabel(" OK "); this.add(OkButton); OkButton.setBackground(Color.lightGray); // Geometry management GridBagConstraints con = new GridBagConstraints(); reset(con); con.gridx = 2; con.gridy = 2; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.NONE; grid.setConstraints(label_1, con); reset(con); con.gridx = 2; con.gridy = 4; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.NONE; grid.setConstraints(label_2, con); reset(con); con.gridx = 2; con.gridy = 5; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.NONE; grid.setConstraints(label_3, con); reset(con); con.gridx = 2; con.gridy = 7; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.BOTH; grid.setConstraints(pic, con); reset(con); con.gridx = 2; con.gridy = 9; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.NONE; grid.setConstraints(OkButton, con); // Resize behavior management and parent heirarchy setLayout(grid); pack(); } 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 synchronized void show() { Rectangle bounds = getParent().bounds(); Rectangle abounds = bounds(); move(bounds.x + (bounds.width - abounds.width)/ 2, abounds.height/2); super.show(); } public boolean handleEvent(Event event) { if (event.id == Event.ACTION_EVENT && event.target == OkButton) { clickedOkButton(); return true; } else if (event.id == Event.WINDOW_DESTROY) { this.hide (); //dispose(); return true; } else return super.handleEvent(event); } public void clickedOkButton() { //handleEvent(new Event(this, Event.WINDOW_DESTROY, null)); this.hide(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -