游戏代码部分-------game包------ActionHandler.java

来源:互联网 发布:ios旧版手机淘宝 编辑:程序博客网 时间:2024/05/18 03:28

package game;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import dialog.*;
import net.*;
import server.*;
/**
 * <p>Title:
俄罗斯方块游戏</p>
 * <p>Description:
基于Internet的俄罗斯方块游戏</p>
 * <p>Copyright: Copyright (c)2005</p>
 * <p>Company: WXHY/u2014ZJC</p>
 * @author
赵建川
 * @version 1.0
 */
/**
 *
负责监听MenuBar的监听器
 *
根据监听到的消息执行游戏组织者的方法
 */
public class ActionHandler implements ActionListener {
  private GameFrame m_tFrame;
  public ActionHandler() {
  }
  /**
   * ActionHandler
的构造器
   * @param tframe
游戏的组织类
   */
  public ActionHandler(GameFrame tframe){
    m_tFrame=tframe;
  }
  /**
   *
回调方法
   * @param e
事件
   */
  public void actionPerformed(ActionEvente)
  {
    String sCommand =e.getActionCommand();
    if      (sCommand.equals("
开始"))     {m_tFrame.startGame();}
    else if (sCommand.equals("
暂停"))     {m_tFrame.pauseGame();}
    else if (sCommand.equals("
结束"))     {m_tFrame.endGame();}
    else if (sCommand.equals("
关闭"))     {m_tFrame.exitGame();}
    else if (sCommand.equals("
设置级别")) { m_tFrame.setLevel();}
    else if (sCommand.equals("
创建游戏")) { m_tFrame.createGame();}
    else if (sCommand.equals("
加入游戏")) { m_tFrame.addGame();}
    else if (sCommand.equals("
退出游戏")) { m_tFrame.exitConn();}
    else if (sCommand.equals("
记录"))    { m_tFrame.seeRecord();}
    else if (sCommand.equals("
关于"))    {m_tFrame.seeAbout();}
    }

}