📄 modulelist.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 : ModuleList.java///* jaNet - A Neural Network Toolkit for Java ----------------------------------------- Author : W.Gander Modifications : 10.09.1996 Filename : ModuleList.java Description : Displays all active modules in the project Modifications : 19.09.1996 L.Patocchi added thread and project management (c) 1996 Biel School of Engineering */package jaNet;import java.awt.*;import java.util.*;public class ModuleList extends Frame implements Runnable{ private List ModuleList; private Button CloseButton; private Panel buttons, listbox; private Thread threadGuard; private int nEntry; private jaNetProject currentPrj; GridBagLayout gridbag = new GridBagLayout(); public ModuleList() { super ("Module List"); this.setBackground(Color.lightGray); // main panel GridBagLayout grid = new GridBagLayout(); int rowHeights[] = {0,10,150,10,30}; int columnWidths[] = {0,10,300,10}; double rowWeights[] = {0.0,0.0,1.0,0.0,0.0}; double columnWeights[] = {0.0,0.0,1.0,0.0}; grid.rowHeights = rowHeights; grid.columnWidths = columnWidths; grid.rowWeights = rowWeights; grid.columnWeights = columnWeights; // Add the list of modules ModuleList = new List(4,false); ModuleList.setFont(new Font("Courier",Font.PLAIN , 12)); this.add(ModuleList); // Add the Close button CloseButton = new Button(); CloseButton.setLabel("Close"); this.add(CloseButton); // Geometry management GridBagConstraints con = new GridBagConstraints(); reset(con); con.gridx = 2; con.gridy = 2; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.BOTH; grid.setConstraints(ModuleList, con); reset(con); con.gridx = 2; con.gridy = 4; con.anchor = GridBagConstraints.CENTER; con.fill = GridBagConstraints.NONE; grid.setConstraints(CloseButton, con); // Resize behavior management and parent heirarchy setLayout(grid); // Default size pack (); //this.resize(400,150); } 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 == CloseButton) { hide (); return true; } if (event.id == Event.WINDOW_DESTROY) { hide (); return true; } return super.handleEvent(event); } public void show(jaNetProject jp) { String item ; nEntry = jp.getModuleCount(); currentPrj = jp; ModuleList.clear(); for (int i=0; i<nEntry; i++){ ModuleEntry me = jp.getModuleEntry(i); if(me.fileName == null){ item = "<unnamed>"; }else{ item = me.fileName; } while(item.length()<15)item = item+" "; item = item + me.classType.ModuleTypeName; ModuleList.addItem(item); } super.show(); // start thread guard. start(); } public void hide() { stop(); super.hide(); }////////////////////////////////////////////////////////////////////// thread guard starter, stopper and body//////////////////////////////////////////////////////////////////// public void start() { if(threadGuard == null){ threadGuard = new Thread(this, "Module list guard"); threadGuard.start(); } } public void stop(){ threadGuard.stop(); threadGuard = null; } public void run(){ String item ; while(true){ nEntry = currentPrj.getModuleCount(); for (int i=0; i<nEntry; i++){ ModuleEntry me = currentPrj.getModuleEntry(i); if(me.fileName == null){ item = "<unnamed>"; }else{ item = me.fileName; } while(item.length()<25)item = item+" "; item = item + me.classType.ModuleTypeName; if(i<ModuleList.countItems()){ if(ModuleList.getItem(i).compareTo(item)!=0){ ModuleList.delItem(i); ModuleList.addItem(item,i); } }else{ ModuleList.addItem(item); } } try {Thread.sleep(500);} catch (InterruptedException e){}; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -