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

📄 articlecontentui.java

📁 <j2me 开发精解> 詹建光著 里所有的源码。对J2me的开发相当有帮助
💻 JAVA
字号:
/*
 * ArticleContentUI.java
 *
 * Created on 2005年11月1日, 下午2:41
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.j2medev.ch5.post.ui;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import com.j2medev.ch5.post.*;
import com.j2medev.ch5.post.model.Article;

/**
 *
 * @author Administrator
 */
public class ArticleContentUI extends TextBox implements CommandListener{
    
    private String title = "";
    private String author = "";
    private UIController controller = null;
    public static final Command backCommand = new Command("返回",Command.BACK, 1);
    public static final Command postCommand = new Command("发表",Command.OK,2);
    /** Creates a new instance of ArticleContentUI */
    public ArticleContentUI(UIController controller) {
        super("输入文章内容", "", 250, TextField.ANY);
        this.controller = controller;
        this.addCommand(postCommand);
        this.addCommand(backCommand);
        this.setCommandListener(this);
    }
    public void init(String author,String title){
        this.author = author;
        this.title = title;
    }
    public void commandAction(Command cmd,Displayable displayable){
        if(cmd == backCommand){
            controller.handleEvent(UIController.EventID.CONTENT_BACK_POST,null);
        }else if(cmd == postCommand){
            Article article = new Article();
            String content = this.getString();
            article.setAuthor(author);
            article.setTitle(title);
            article.setContent(content);
            controller.handleEvent(UIController.EventID.POST_ARTICLE, new Object[]{article});
        }
    }
}

⌨️ 快捷键说明

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