import java.io.IOException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
public class ItemTestMIDlet2 extends MIDlet implements CommandListener {
private Display display;
private Command exit_cmd;
private Image game_img;
private Form form;
private TextField textfield;
private DateField datefield;
private ImageItem imageitem;
private Spacer space1, space2;
public ItemTestMIDlet2() {
try{
game_img = Image.createImage("/game_img.png");
} catch(IOException e) { }
space1 = new Spacer(10,30);
space2 = new Spacer(10,40);
form = new Form("Form Test");
textfield = new TextField("텍스트 필드", "왼쪽 정렬 : " , 10, TextField.ANY);
textfield.setLayout(Item.LAYOUT_LEFT);
form.append(textfield);
form.append(space1);
datefield = new DateField("날짜 및 시간(가운데정렬)", DateField.DATE_TIME);
datefield.setLayout(Item.LAYOUT_CENTER);
form.append(datefield);
form.append(space2);
imageitem = new ImageItem("게임 케릭터(오른쪽 정렬)", game_img, ImageItem.LAYOUT_DEFAULT,
"게임 케릭터 제공할 수 없음");
imageitem.setLayout(Item.LAYOUT_RIGHT);
form.append(imageitem);
exit_cmd = new Command("Exit", Command.EXIT, 1);
form.addCommand(exit_cmd);
form.setCommandListener(this);
display = Display.getDisplay(this);
} // 생성자 끝
protected void destroyApp(boolean arg0) {
}
protected void pauseApp() {
}
protected void startApp() {
display.setCurrent(form);
}
public void commandAction ( Command c, Displayable d) {
if(c == exit_cmd ){
destroyApp(true);
notifyDestroyed();
}
}
}
Spacer 넣기 전
Spacer 넣은 후