本文整理汇总了Java中javax.microedition.lcdui.Alert类的典型用法代码示例。如果您正苦于以下问题:Java Alert类的具体用法?Java Alert怎么用?Java Alert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Alert类属于javax.microedition.lcdui包,在下文中一共展示了Alert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AndroidAlertUI
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
/**
* Depending on the properties, the Alert can be rendered as a Toast or
* Alert.
*
* @see #isToastable()
* @see #showNotifyAsToast()
*/
public AndroidAlertUI(final MicroEmulatorActivity activity,
final Alert alert) {
super(activity, alert, false);
displayableUnboxed = alert;
activity.post(new Runnable() {
public void run() {
alertDialog = new AlertDialog.Builder(activity).create();
if (alert.getTitle() != null) {
alertDialog.setTitle(alert.getTitle());
}
onClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
activity.setDialog(null);
MIDletBridge.getMIDletAccess().getDisplayAccess().commandAction(
buttons.get(which).getCommand(), displayable);
}
};
}
});
}
示例2: buttonize
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
private void buttonize(CommandUI cmd) {
int which = 0;
Command command = cmd.getCommand();
if (command == Alert.DISMISS_COMMAND) {
which = DialogInterface.BUTTON_NEUTRAL;
} else {
switch (command.getCommandType()) {
case Command.OK:
which = DialogInterface.BUTTON_POSITIVE;
break;
case Command.CANCEL:
which = DialogInterface.BUTTON_NEGATIVE;
break;
}
}
if (which == 0) {
alertDialog.setButton(command.getLabel(), onClickListener);
which = DialogInterface.BUTTON_POSITIVE;
} else {
alertDialog.setButton(which, command.getLabel(), onClickListener);
}
buttons.put(which, cmd);
}
示例3: _commandAction
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public void _commandAction(Command com, Displayable d) {
if (d instanceof Alert) {
J2MEDisplay.setView(this.manager);
}
if (d == manager) {
String action = manager.getString(manager.getSelectedIndex());
if (action.equals(CLEAR_LOGS)) {
clearLogs();
}
if (action.equals(VIEW_LOGS)) {
viewLogs();
}
if (action.equals(SEND_LOGS)) {
sendLogs();
}
if (com.equals(EXIT)) {
done();
}
} else if (d == viewer) {
J2MEDisplay.setView(this.manager);
}
}
示例4: Screen
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public Screen(Display display) {
super();
this.setFullScreenMode(true);
this.parentDisplay = display;
updateOrientation();
try {
// Create background image
this.background = Image.createImage("midlets/blogwriter/images/Background.png");
} catch (IOException e) {
this.parentDisplay.setCurrent(
new Alert("Cannot create graphics."), this);
}
VirtualKeyboard.setVisibilityListener(this);
}
示例5: showLoginRequiredMessage
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
/**
* Show a login required message on the screen.
*
* @param title
* @param alertText
* @param type
*/
public final void showLoginRequiredMessage() {
Alert alert = new Alert(LOGIN_REQUIRED_LABEL, LOGIN_REQUIRED_TEXT,
null, AlertType.INFO);
alert.addCommand(new Command(LOGIN_REQUIRED_YES, Command.OK, 0));
alert.addCommand(new Command(LOGIN_REQUIRED_NO, Command.CANCEL, 0));
alert.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
if(c.getCommandType() == Command.OK) {
showLoginView();
} else {
setDisplay(self);
}
}
});
setDisplay(alert);
}
示例6: commandAction
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public void commandAction(Command cmd, Displayable disp) {
//#debug info
System.out.println("commandAction with cmd=" + cmd.getLabel() + ", screen=" + disp );
if (cmd == this.backCommand) {
display.setCurrent(mainScreen);
} else if (cmd == this.exitCommand) {
//#debug info
System.out.println("Exit application");
this.notifyDestroyed();
} else if (cmd == this.aboutCommand) {
String param = this.getAppProperty("Xfolite-Version");
Alert alert = new Alert(
Locale.get("main.label.about"),
Locale.get("main.msg.about", param),
null,
AlertType.INFO);
// Looks like an error but builds
this.display.setCurrent(alert, mainScreen);
}
}
示例7: inquiryCompleted
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public void inquiryCompleted(int complete) {
log("device discovery is completed with return code:" + complete);
log("" + devices.size() + " devices are discovered");
deviceReturnCode = complete;
if (devices.size() == 0) {
Alert alert = new Alert("Bluetooth", "No Bluetooth device found", null, AlertType.INFO);
alert.setTimeout(3000);
remotedeviceui.showui();
display.setCurrent(alert, remotedeviceui);
} else {
remotedeviceui.showui();
display.setCurrent(remotedeviceui);
}
}
示例8: showEaster
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
private void showEaster()
{
if (easter > 99) {
easter = 0;
try {
Image[] images = new Image[2];
images[0] = Image.createImage(IMG_TREASURE);
images[1] = Image.createImage(IMG_TREASURE2);
Animation ac = new Animation(images, getDisplay());
Alert alert = new Alert(" You found a treasure!", null, null,
AlertType.ALARM);
alert.setTimeout(5000);
display.setCurrent(alert, ac);
ac.addCommand(homeCommand);
ac.setCommandListener(this);
ac.startAnimation();
} catch (IOException e) {
throw new JSimpleDiceException(EXCEPTION_MSG + e.getMessage());
}
}
}
示例9: showFatalErrorAndQuit
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public void showFatalErrorAndQuit() {
Alert alert = new Alert("Fatal Error!", Log.getLogContent(), null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
javax.microedition.lcdui.Display.getDisplay(this).setCurrent(alert);
alert.setCommandListener(new CommandListener() {
public void commandAction(javax.microedition.lcdui.Command command, Displayable displayable) {
synchronized (this){
this.notify();
}
}
});
try {
synchronized (this){
this.wait();
}
} catch (InterruptedException e) {
}
this.destroyApp(true);
}
示例10: test
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public void test(TestHarness th) {
Alert alert = new Alert("Hello World", "Some text", null, AlertType.INFO);
alert.setTimeout(Alert.FOREVER);
TextEditor textEditor = TextEditor.createTextEditor("Hello, world!", 20, 0, 100, 24);
textEditor.setParent(this);
th.setScreenAndWait(this);
textEditor.setFocus(true);
th.check(textEditor.hasFocus(), "TextEditor gained focus");
th.check(isTextEditorReallyFocused(), "TextEditor really gained focus");
th.setScreenAndWait(alert);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
th.fail("Unexpected exception: " + e);
}
th.check(textEditor.hasFocus(), "TextEditor kept focus");
th.check(!isTextEditorReallyFocused(), "TextEditor really lost focus");
th.setScreenAndWait(this);
th.check(textEditor.hasFocus(), "TextEditor maintained focus");
th.check(isTextEditorReallyFocused(), "TextEditor really regained focus");
th.setScreenAndWait(alert);
th.check(textEditor.hasFocus(), "TextEditor still has focus");
th.check(!isTextEditorReallyFocused(), "TextEditor really lost focus");
}
示例11: startApp
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
protected void startApp() throws MIDletStateChangeException {
try {
System.out.println("FileConnection " + System.getProperty("microedition.io.file.FileConnection.version"));
this.list.setDir(null);
setCurrentDisplayable(this.list);
} catch (SecurityException e) {
Alert alert = new Alert("Error", "Unable to access the restricted API", null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
setCurrentDisplayable(alert);
}
}
示例12: showResultImage
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
private void showResultImage()
{
try {
img = Image.createImage("/img/" + result + ".png");
} catch (IOException e) {
throw new JSimpleDiceException(EXCEPTION_MSG + e.getMessage());
}
Alert alert = new Alert(String.valueOf(result), null, img,
AlertType.INFO);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert, form);
}
示例13: createAlertUI
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public AlertUI createAlertUI(Alert alert) {
return new AndroidAlertUI(activity, alert);
}
示例14: EditScreen
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
EditScreen(Display display) {
super(display);
this.titleTextBox = new CanvasTextBox(this, "Title", TextField.ANY,
this.maximumTextLength);
this.titleTextBox.setTextEditorListener(this);
if (!BlogWriter.isFullTouch() && !BlogWriter.isAshaPlatform()) {
this.titleTextBox.setFocused(true);
}
this.contentTextBox = new CanvasTextBox(this, "Post", TextField.ANY,
this.maximumTextLength, true);
this.contentTextBox.setTextEditorListener(this);
try {
this.exitButton = new Button(this, "Exit", new Runnable() {
public void run() {
// When Exit is tapped, close the application
removeItems();
Display.getDisplay(parent).setCurrent(null);
parent.notifyDestroyed();
}
});
this.publishButton = new Button(this, "Publish", new Runnable() {
public void run() {
// Show alert when the Publish button is tapped
parentDisplay.setCurrent(new Alert("Publish",
"Post published successfully.", null,
AlertType.INFO));
}
});
this.publishButton.setEnabled(false);
} catch (Exception ex) {
this.parentDisplay.setCurrent(new Alert("Cannot create controls."),
this);
}
// Set default position of items and buttons
this.layoutControls();
this.titleTextBox.setVisible(true);
this.contentTextBox.setVisible(true);
}
示例15: LoginScreen
import javax.microedition.lcdui.Alert; //导入依赖的package包/类
public LoginScreen(Display display) {
super(display);
try {
this.userNameTextBox = new CanvasTextBox(
this, "Login", TextField.ANY, this.maxLoginLength);
this.userNameTextBox.setTextEditorListener(this);
this.passwordTextBox = new CanvasTextBox(
this, "Password", TextField.PASSWORD, this.maxLoginLength);
this.passwordTextBox.setTextEditorListener(this);
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
this.parentDisplay.setCurrent(
new Alert("e1 " + e1),
this);
//e1.printStackTrace();
}
//Disable Password box. It will be enabled once username is not empty.
this.passwordTextBox.setEnabled(false);
try {
this.exitButton = new Button(
this, "Exit",
new Runnable() {
public void run() {
// When Exit is tapped, close the application
removeItems();
Display.getDisplay(parent).setCurrent(null);
parent.notifyDestroyed();
}
});
this.loginButton = new Button(
this, "Log in",
new Runnable() {
public void run() {
// When Login is tapped, create a new screen and set it current
if(BlogWriter.isAshaPlatform())
removeItems();
EditScreen editScreen = new EditScreen(parentDisplay);
editScreen.setParent(parent);
parentDisplay.setCurrent(editScreen);
}
});
// Disable Login button - it is enabled once username and password are entered
this.loginButton.setEnabled(false);
} catch (Exception ex) {
this.parentDisplay.setCurrent(
new Alert("Cannot create controls."),
this);
}
// Create the logo image
try {
this.logoImage = Image.createImage("midlets/blogwriter/images/LogoImage.png");
} catch (IOException e) {
this.parentDisplay.setCurrent(
new Alert("Cannot create graphics."), this);
}
// Set the default position of items and buttons
this.layoutControls();
this.userNameTextBox.setVisible(true);
if (!BlogWriter.isFullTouch() && !BlogWriter.isAshaPlatform()) {
this.userNameTextBox.setFocused(true);
}
this.passwordTextBox.setVisible(true);
}