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

📄 msgctrlbase.java

📁 J2me实现的MSN Messeger客户端程序。聊天、添加好友、删除好友、阻止好友
💻 JAVA
字号:
package vitular.ui;
import javax.microedition.lcdui.*; //MIDP1.0 适应

abstract public class MsgCtrlBase
    extends Object {

  //控件可显示的屏幕区域
  public int left, top; //图顶点
  public int width, height; //长宽

  public int posX, posY; //显示位置
  protected CtrlListener listener = null;
  public boolean visible = true; //是否显示
  public boolean active = true; //是否激活

  public static final int EVT_ITEM_FOCUS = 1001;
  public static final int EVT_MENU_SELECT = 1002;
  public static final int EVT_MENU_CLOSE = 1004;
  public static final int EVT_BUTTON_SELECT = 1005;
  public static final int EVT_SPLASH_CLOSE = 1006;
  public static final int EVT_TEXTBOARD_CLOSE = 1007;

  protected  Font textFont;//字体
  protected MsgCanvas canvas;//记录自己的父窗口

  public MsgCtrlBase(MsgCanvas canvas) {
    this(canvas, 0, 0, canvas.getWidth(), canvas.getRealHeight());
  }
  /**
   *构造函数<br>
   *Left、Top:控件绘图顶点<br>
   *Width、Height:控件绘图长宽
   */
  public MsgCtrlBase(MsgCanvas canvas, int Left, int Top, int Width, int Height) {
    this.canvas = canvas;
    setRect(Left, Top, Width, Height);
    init();
  }

  /**
   *做一些初始化的工作
   */
  private void init(){
    //取得字体
    textFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
  }

  /**
   *设置控件绘图区域
   */
  private void setRect(int Left, int Top, int Width, int Height) {
    left = Left;
    top = Top;
    width = Width;
    height = Height;
  }

  /**
   * 显示顶点位置
   * @param x int
   * @param y int
   */
  public void setPosition(int x, int y) {
    posX = x;
    posY = y;
  }

  /**
   * 设置是否可见
   * @param Visible boolean
   */
  public void setVisible(boolean Visible) {
    visible = Visible;
  }

  /**
   * 是否可见
   * @return boolean
   */
  public boolean isVisible() {
    return visible;
  }

  /**
   * 是否激活
   * @return boolean
   */
  public boolean isActive() {
    return active;
  }

  /**
   * 设置激活状态
   * @param Active boolean
   */
  public void setActive(boolean Active) {
    active = Active;
  }

  /**
   * 发送事件
   * @param EventId int
   * @param Value int
   * @param ValueName String
   */
  protected final void dispatchEvent(int EventId, int Value, String ValueName) {
    if (listener != null) {
      listener.CtrlAction(this, EventId, Value, ValueName);
    }
  }

  /**
   *设置监听
   */
  public void setListener(CtrlListener Listener) {
    listener = Listener;
  }

  public void update(Graphics g){
  this.setRect(0, 0, canvas.getWidth(), canvas.getRealHeight());
   updateSelf(g);
   canvas.flushGraphics();
  }

  /**
   * 取得字体
   * @return Font
   */
  public Font getFont(){
    return textFont;
  }
  /**
   * 子类必须重载这个方法画字自己的内容
   * @param g Graphics
   */
  abstract protected void updateSelf(Graphics g);

}

⌨️ 快捷键说明

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