/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* @author user
*/
public class Utama extends MIDlet implements CommandListener{
Display tampilan;
Form frmLogin, frmGambar;
TextField txtUsername, txtPassword;
Command cmdLogin, cmdExit;
Image imgContoh1, imgContoh2;
Alert error1, error2, error3, error4;
List lstMenu;
public Utama(){
tampilan = Display.getDisplay(this);
frmLogin = new Form("LOGIN PAGE");
frmGambar = new Form("TAMPILAN GAMBAR");
txtUsername = new TextField("Username :", "",10,TextField.NUMERIC);
txtPassword = new TextField("Password :", "",4,TextField.PASSWORD);
cmdLogin = new Command("LOGIN",Command.ITEM,2);
cmdExit = new Command("EXIT",Command.EXIT,2);
try {
imgContoh1 = Image.createImage("/persia.jpg");
imgContoh2 = Image.createImage("/anggora.jpg");
} catch (IOException ex) {
ex.printStackTrace();
}
lstMenu = new List("TAMPILAN MENU", List.IMPLICIT);
lstMenu.append("KE FORM LOGIN", null);
lstMenu.append("KE TAMPILAN MENU 2", null);
lstMenu.append("KE TAMPILAN MENU 3", null);
lstMenu.setCommandListener(this);
//loadingForm1();
//loadingForm2();
}
public void startApp() {
tampilan.setCurrent(lstMenu);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c,Displayable d){
if (c == List.SELECT_COMMAND){
switch(lstMenu.getSelectedIndex()){
case 0 : tampilan.setCurrent(frmLogin); break;
case 1 : tampilan.setCurrent(frmGambar);break;
case 2 : notifyDestroyed(); break;
}
}
if (d == frmLogin){
if (c == cmdExit){
tampilan.setCurrent(lstMenu);
}
}
}
public void loadingForm1(){
frmLogin.append(txtUsername);
frmLogin.append(txtPassword);
frmLogin.addCommand(cmdLogin);
frmLogin.addCommand(cmdExit);
frmLogin.setCommandListener(this);
}
public void loadingForm2(){
frmGambar.append(new ImageItem(null,imgContoh1,ImageItem.LAYOUT_CENTER,null));
frmGambar.append(new ImageItem(null,imgContoh2,ImageItem.LAYOUT_BOTTOM,null));
frmGambar.addCommand(cmdExit);
frmGambar.setCommandListener(this);
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* @author user
*/
public class Utama extends MIDlet implements CommandListener{
Display tampilan;
Form frmLogin, frmGambar;
TextField txtUsername, txtPassword;
Command cmdLogin, cmdExit;
Image imgContoh1, imgContoh2;
Alert error1, error2, error3, error4;
List lstMenu;
public Utama(){
tampilan = Display.getDisplay(this);
frmLogin = new Form("LOGIN PAGE");
frmGambar = new Form("TAMPILAN GAMBAR");
txtUsername = new TextField("Username :", "",10,TextField.NUMERIC);
txtPassword = new TextField("Password :", "",4,TextField.PASSWORD);
cmdLogin = new Command("LOGIN",Command.ITEM,2);
cmdExit = new Command("EXIT",Command.EXIT,2);
try {
imgContoh1 = Image.createImage("/persia.jpg");
imgContoh2 = Image.createImage("/anggora.jpg");
} catch (IOException ex) {
ex.printStackTrace();
}
lstMenu = new List("TAMPILAN MENU", List.IMPLICIT);
lstMenu.append("KE FORM LOGIN", null);
lstMenu.append("KE TAMPILAN MENU 2", null);
lstMenu.append("KE TAMPILAN MENU 3", null);
lstMenu.setCommandListener(this);
//loadingForm1();
//loadingForm2();
}
public void startApp() {
tampilan.setCurrent(lstMenu);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c,Displayable d){
if (c == List.SELECT_COMMAND){
switch(lstMenu.getSelectedIndex()){
case 0 : tampilan.setCurrent(frmLogin); break;
case 1 : tampilan.setCurrent(frmGambar);break;
case 2 : notifyDestroyed(); break;
}
}
if (d == frmLogin){
if (c == cmdExit){
tampilan.setCurrent(lstMenu);
}
}
}
public void loadingForm1(){
frmLogin.append(txtUsername);
frmLogin.append(txtPassword);
frmLogin.addCommand(cmdLogin);
frmLogin.addCommand(cmdExit);
frmLogin.setCommandListener(this);
}
public void loadingForm2(){
frmGambar.append(new ImageItem(null,imgContoh1,ImageItem.LAYOUT_CENTER,null));
frmGambar.append(new ImageItem(null,imgContoh2,ImageItem.LAYOUT_BOTTOM,null));
frmGambar.addCommand(cmdExit);
frmGambar.setCommandListener(this);
}
}
Tidak ada komentar:
Posting Komentar