www.pudn.com > WordTip.zip > SearchWord.java
/*
* Created on 2005-1-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package net.hyweb.ui;
import javax.microedition.lcdui.*;
/**
* @author user
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SearchWord extends Form implements CommandListener, ItemStateListener{
private UIController uicontroller;
private TextField wordField;
private Command searchCommand;
private Command backCommand;
private ChoiceGroup searchAuto;
/**
* @param arg0
*/
public SearchWord(UIController uicontroller) {
super("SearchWord");
this.uicontroller = uicontroller;
wordField = new TextField("Searching word...", "", 20, TextField.ANY);
searchAuto = new ChoiceGroup("AutoSearch", Choice.MULTIPLE);
searchAuto.append("YES", null);
searchCommand = new Command("Search", Command.OK, 1);
backCommand = new Command("Back", Command.BACK, 2);
this.append(wordField);
this.append(searchAuto);
searchAuto.setSelectedIndex(0, true);
this.addCommand(searchCommand);
this.addCommand(backCommand);
this.setCommandListener(this);
this.setItemStateListener(this);
}
public void init(){
this.wordField.setString("");
}
public void itemStateChanged(Item item) {
if(item == wordField){
if(searchAuto.isSelected(0)){
String input = this.wordField.getString().trim();
if(input.length() != 0){
uicontroller.EventController
(EventID.SEARCH_AUTO, new Object[]{input});
}
}
}
}
public void commandAction(Command command, Displayable arg1) {
if(command == this.searchCommand){
//手动搜索
uicontroller.EventController
(EventID.SEARCH_MANUAL, new Object[]{this.wordField.getString().trim()});
}else{
//回主界面
uicontroller.EventController(EventID.UI_MAIN);
}
}
}