【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了TheWorld.java提供大家参考,希望对大家有所帮助!
package com.javapatterns.command.javaawt;
import java.awt.*;
import java.awt.event.*;
public class TheWorld extends Frame implements ActionListener
{
LetThereBeLightCommand btnLight;
LetThereBeLandCommand btnLand;
ResetCommand btnReset;
GodRestsCommand btnExit;
Panel p;
public TheWorld()
{
super("This is the world, and God says...");
p = new Panel();
p.setBackground(Color.black);
add(p);
btnLight = new LetThereBeLightCommand("Let there be light", p);
btnLand = new LetThereBeLandCommand("Let there be land", p);
btnReset = new ResetCommand("Reset", p);
btnExit = new GodRestsCommand("God rests");
p.add(btnLight);
p.add(btnLand);
p.add(btnReset);
p.add(btnExit);
btnLight.addActionListener(this);
btnLand.addActionListener(this);
btnReset.addActionListener(this);
btnExit.addActionListener(this);
setBounds(100,100,400,200);
setVisible(true);
}
//-----------------------------------------
public void actionPerformed(ActionEvent e)
{
CommandFromGod obj = (CommandFromGod)e.getSource();
obj.Execute();
}
//-----------------------------------------
static public void main(String[] argv)
{
new TheWorld();
}
}
上一篇:
TheMonk.java
下一篇:
法律专业开题报告范文