📄 editmoduletype.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 : editModuleType.java//package jaNet;
import java.awt.*;
public class editModuleType extends Dialog {
public TextField entryModuleName;
public TextField entryClassName;
public Button buttonOk;
public Button buttonCancel;
private OptionsBox dearParent;
private String tempModuleName, origModuleName;
private String tempClassName, origClassName;
public void show(String moduleName, String className) {
tempModuleName = moduleName;
origModuleName = moduleName;
tempClassName = className;
origClassName = className;
entryModuleName.setText(moduleName);
entryClassName.setText(className);
super.show();
}
public boolean handleEvent(Event event) {
if (event.id == Event.KEY_RELEASE && event.target == entryModuleName) {
tempModuleName = entryModuleName.getText();
return super.handleEvent(event);
}else
if (event.id == Event.KEY_RELEASE && event.target == entryClassName) {
tempClassName = entryClassName.getText();
return super.handleEvent(event);
}else
if (event.id == Event.ACTION_EVENT && event.target == buttonOk) {
clickedButtonOk();
return true;
}else
if (event.id == Event.ACTION_EVENT && event.target == buttonCancel) {
clickedButtonCancel();
return true;
}else
if (event.id == Event.WINDOW_DESTROY) {
hide();
return true;
}
return super.handleEvent(event);
}
public void clickedButtonOk() {
if(tempModuleName.compareTo(origModuleName) != 0 ||
tempClassName.compareTo(origClassName) != 0){
dearParent.setModuleType(tempModuleName, tempClassName);
}
this.hide();
}
public void clickedButtonCancel() {
this.hide();
}
public editModuleType(Frame container, Dialog parent) {
super(container, "Edit Module Type", false);
Label label_1;
Label label_2;
Separator separator;
// this is my parent
dearParent = (OptionsBox) parent;
this.setBackground(Color.lightGray);
// main panel
GridBagLayout grid = new GridBagLayout();
int rowHeights[] = {0,6,25,30,10,30,5};
int columnWidths[] = {0,5,30,75,60,60,75,30,5};
double rowWeights[] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0};
double columnWeights[] = {0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0};
grid.rowHeights = rowHeights;
grid.columnWidths = columnWidths;
grid.rowWeights = rowWeights;
grid.columnWeights = columnWeights;
label_1 = new Label();
label_1.setText("Module name");
this.add(label_1);
label_2 = new Label();
label_2.setText("Class name");
this.add(label_2);
entryModuleName = new TextField(20);
this.add(entryModuleName);
entryClassName = new TextField(20);
this.add(entryClassName);
separator = new Separator(Separator.HORIZONTAL);
separator.perSide = 0;
separator.rise = Separator.IN;
this.add(separator);
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 = 2;
con.gridy = 2;
con.gridwidth = 3;
con.anchor = GridBagConstraints.CENTER;
con.fill = GridBagConstraints.HORIZONTAL;
grid.setConstraints(label_1, con);
reset(con);
con.gridx = 5;
con.gridy = 2;
con.gridwidth = 3;
con.anchor = GridBagConstraints.CENTER;
con.fill = GridBagConstraints.HORIZONTAL;
grid.setConstraints(label_2, con);
reset(con);
con.gridx = 2;
con.gridy = 3;
con.gridwidth = 3;
con.anchor = GridBagConstraints.CENTER;
con.fill = GridBagConstraints.HORIZONTAL;
grid.setConstraints(entryModuleName, con);
reset(con);
con.gridx = 5;
con.gridy = 3;
con.gridwidth = 3;
con.anchor = GridBagConstraints.CENTER;
con.fill = GridBagConstraints.HORIZONTAL;
grid.setConstraints(entryClassName, con);
reset(con);
con.gridx = 1;
con.gridy = 4;
con.gridwidth = 8;
con.anchor = GridBagConstraints.CENTER;
con.fill = GridBagConstraints.BOTH;
grid.setConstraints(separator, 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 = 6;
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();
}
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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -