📄 testcomp1.java
字号:
package janetsim.component;
import janetsim.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestComp1 extends SimComponent implements SimCommand,ActionListener {
SimParameter parm1=null;
SimParamDouble testparm=null;
public TestComp1(String name,String aClass,Sim aSim,int x,int y) {
super(name,aClass,aSim,x,y);
SimParameter p=new SimParameter("param1",this,theSim.now(),false);
addParameter(p);
parm1=new SimParameter("param2",this,theSim.now(),true);
addParameter(parm1);
p=new SimParameter("dfdparsd asdd m2",this,theSim.now(),false);
addParameter(p);
testparm=new SimParamDouble("parsdf sd am2",this,theSim.now(),true,true,0);
addParameter(testparm);
}
public void pause() {
removeParameter(parm1);
}
public void start() {
theSim.enqueue(new SimEvent(SimProvider.EV_PRIVATE+1,this,this,
theSim.now()+SimClock.MSec2Tick(1),null));
}
public void reset() {
testparm.setValue(0,theSim.now(),1);
testparm.update(theSim.now());
}
public void action(SimEvent e) {
testparm.setValue(Math.random(),theSim.now(),1);
theSim.enqueue(new SimEvent(SimProvider.EV_PRIVATE+1,this,this,
theSim.now()+SimClock.MSec2Tick(1),null));
}
public SimCommand querySimCommand(int selectedCount) {
return this;
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Item 1")) {
removeParameter(parm1);
}
else if(e.getActionCommand().equals("Item 23")) {
parm1=new SimParameter("par!!!am2",this,theSim.now(),true);
addParameter(parm1);
}
}
public java.util.List getCommand(Sim aSim,SimGUI aGUI) {
java.util.List cmd=new java.util.ArrayList();
JMenu menu=new JMenu("Menu 1");
JMenuItem menuItem=new JMenuItem("Item 1");
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem=new JMenuItem("Item 23");
menuItem.addActionListener(this);
cmd.add(menu);
cmd.add(menuItem);
return cmd;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -