⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 theworld.java

📁 Java与模式 源代码
💻 JAVA
字号:
package com.javapatterns.command.javaawt;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TheWorld extends Frame implements ActionListener
{
    private LetThereBeLightCommand btnLight;
    private LetThereBeLandCommand btnLand;
    private ResetCommand btnReset;
    private GodRestsCommand btnExit;
    private 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();
    }

    //-----------------------------------------
    public static void main(String[] argv)
    {
        new TheWorld();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -