www.pudn.com > WordTip.zip > DetailedWord.java
/*
* Created on 2005-2-1
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package net.hyweb.ui;
import java.util.*;
import java.util.Calendar;
import javax.microedition.lcdui.*;
import net.hyweb.wordmodel.*;
/**
* @author user
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class DetailedWord extends Form implements CommandListener{
private UIController uicontroller;
private Word word = null;
private byte sourceWindow = 0;
private Command exitCommand;
private TextField enwordField;
private TextField cnwordField;
private TextField detailField;
private TextField dateTimeField;
/**
* @param arg0
*/
public DetailedWord(UIController uicontroller) {
super("DetailedWord");
this.uicontroller = uicontroller;
enwordField = new TextField("English Word", "", 20, TextField.UNEDITABLE);
cnwordField = new TextField("Explaination", "", 20, TextField.UNEDITABLE);
detailField = new TextField("Details", "", 60, TextField.UNEDITABLE);
dateTimeField = new TextField("DateTime", "", 60, TextField.UNEDITABLE);
this.append(enwordField);
this.append(cnwordField);
this.append(detailField);
this.append(dateTimeField);
exitCommand = new Command("Back", Command.ITEM, 1);
this.addCommand(exitCommand);
setCommandListener(this);
}
public void init(){
if(this.word != null){
TimeZone tz = TimeZone.getDefault();
Calendar cal = Calendar.getInstance(tz);
Date date = new Date(word.getDateTime());
cal.setTime(date);
String dateShow = cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DAY_OF_MONTH);
this.dateTimeField.setString(dateShow);
this.detailField.setString(word.getDetail());
this.cnwordField.setString(word.getCnWord());
this.enwordField.setString(word.getEnWord());
this.word = null;
}
}
/**
* @return Returns the word.
*/
public Word getWord() {
return word;
}
/**
* @param word The word to set.
*/
public void setWord(Word word) {
this.word = word;
}
public void commandAction(Command command, Displayable arg1) {
if(command == this.exitCommand){
if(this.sourceWindow == EventID.SEARCH_WORD){
uicontroller.EventController(EventID.SEARCH_WORD);
}else{
uicontroller.EventController(EventID.VIEW_ALL);
}
}
}
/**
* @return Returns the sourceWindow.
*/
public byte getSourceWindow() {
return sourceWindow;
}
/**
* @param sourceWindow The sourceWindow to set.
*/
public void setSourceWindow(byte sourceWindow) {
this.sourceWindow = sourceWindow;
}
}