searchform.java

来自「基于J2ME」· Java 代码 · 共 49 行

JAVA
49
字号
package com.yxw.view;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.*;
import com.yxw.control.*;
public class SearchForm extends Form implements CommandListener {

	private Command submit;
	private Command cancel;
	private TextField keyword;
	public SearchForm(String arg0) {
		super(arg0);
		this.submit=new Command("确定",Command.ITEM,1);
		this.cancel=new Command("返回",Command.CANCEL,2);
		this.keyword=new TextField("输入歌曲名:","",20,TextField.ANY);
		this.addCommand(this.submit);
		this.addCommand(this.cancel);
		this.append(this.keyword);
		this.setCommandListener(this);
		//this.append(this.keyword);
		// TODO 自动生成构造函数存根
	}

	public SearchForm(String arg0, Item[] arg1) {
		super(arg0, arg1);
		// TODO 自动生成构造函数存根
	}

	public void commandAction(Command arg0, Displayable arg1) {
		// TODO 自动生成方法存根

		if(arg0==this.submit){
			StringBuffer sb=new StringBuffer();
			//sb.append("http://localhost/r.mp3");
			sb.append("http://localhost/YYServer/queryMusic?key=");
			sb.append(this.keyword.getString());
			System.out.println(sb.toString());
			MainMidlet.forward(new WaitFlash("正在下载结果列表....",sb.toString()));
		}else if(arg0==this.cancel){
			MainMidlet.goBack();
		}
	}

}

⌨️ 快捷键说明

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