⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 madvertising.java

📁 是一个wap+java的不错的例子
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MAdvertising extends MIDlet
implements CommandListener {
Display display = null;
List menu = null;
List choose = null;
List choose1 = null;
List choose2 = null;
List choose3 = null;
Ticker ticker = new Ticker("Mobile Components");
static final Command backCommand = new Command("Back",
Command.BACK, 0);
static final Command mainMenuCommand = new Command("Main",
Command.SCREEN, 1);
static final Command exitCommand = new Command("Exit",
Command.STOP, 2);
String currentMenu = null;
public MAdvertising() { }
public void startApp()
throws MIDletStateChangeException {
display = Display.getDisplay(this);
menu = new List("Advertising Products", Choice.IMPLICIT);
menu.append("Cosmetics", null);
menu.append("Jewelry", null);
menu.append("Books", null);
menu.append("Clothing", null);
menu.addCommand(exitCommand);
menu.setCommandListener(this);
menu.setTicker(ticker);
mainMenu();
}
public void pauseApp() {
display = null;
choose = null;
choose1 = null;
choose2 = null;
choose3 = null;
menu = null;
ticker = null;
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
//Main menu
void mainMenu() {
display.setCurrent(menu);
currentMenu = "Main";
}
public void testCosmetics() {
choose = new List("Cosmetic Products", Choice.MULTIPLE);
choose.setTicker(new Ticker("Cosmetics..."));
choose.addCommand(backCommand);
choose.setCommandListener(this);
choose.append("Nail Polish", null);
choose.append("Body Lotion", null);
choose.append("Body Spray", null);
display.setCurrent(choose);
currentMenu = "Cosmetics";
}
public void testJewelry() {
choose1 = new List("Jewelry", Choice.MULTIPLE);
choose1.setTicker(new Ticker("Jewelry..."));
choose1.addCommand(backCommand);
choose1.setCommandListener(this);
choose1.append("Earrings", null);
choose1.append("Necklace", null);
choose1.append("Bracelets", null);
display.setCurrent(choose1);
currentMenu = "Jewelry";
}
public void testBooks() {
choose2 = new List("Books", Choice.MULTIPLE);
choose2.setTicker(new Ticker("Books..."));
choose2.addCommand(backCommand);
choose2.setCommandListener(this);
choose2.append("Java", null);
choose2.append("VB", null);
choose2.append("VC", null);
display.setCurrent(choose2);
currentMenu = "Books";
}
public void testFashion() {
choose3 = new List("Clothing", Choice.MULTIPLE);
choose3.setTicker(new Ticker("Clothing..."));
choose3.addCommand(backCommand);
choose3.setCommandListener(this);
choose3.append("Trousers", null);
choose3.append("T-Shirts", null);
choose3.append("Jeans", null);
display.setCurrent(choose3);
currentMenu = "Clothing";
}
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("Exit")) {
destroyApp(true);
} else if (label.equals("Back")) {
if(currentMenu.equals("Cosmetics") ||
currentMenu.equals("Jewelry") ||
currentMenu.equals("Books") ||
currentMenu.equals("Clothing")) {
// go back to menu
mainMenu();
}
} else {
List down = (List)display.getCurrent();
switch(down.getSelectedIndex()) {
case 0: testCosmetics();break;
case 1: testJewelry();break;
case 2: testBooks();break;
case 3: testFashion();break;
}
}
}
}

⌨️ 快捷键说明

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