javax.microedition.lcdui.Command Java Examples

The following examples show how to use javax.microedition.lcdui.Command. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseFormView.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: CommentsView.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == commentCommand) {
        openDetailsView(null);
    }
    else if (command == backCommand) {
        abortLoadingComments();
        backListener.backCommanded();
    }
    else if (command == refreshCommand) {
        refresh();
    }
    else if (command == aboutCommand) {
        showAboutView();
    }
    else if (command == loginCommand) {
        showLoginView();
    }
    else if (command == logoutCommand) {
        session.setLoggedOut();
        setupCommands();
    }
}
 
Example #3
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void setCommands(Vector v) {
    if(currentCommands != null) {
        for(int iter = 0 ; iter < currentCommands.length ; iter++) {
            removeCommand(currentCommands[iter]);
        }
    }
    setCommandListener(this);
    currentCommands = new Command[v.size()];
    com.codename1.ui.Command backCommand = null;
    if(Display.getInstance().getCurrent() != null) {
        backCommand = Display.getInstance().getCurrent().getBackCommand();
    }
    for(int iter = 0 ; iter < currentCommands.length ; iter++) {
        com.codename1.ui.Command current = (com.codename1.ui.Command)v.elementAt(iter);
        if(current == backCommand) {
            currentCommands[iter] = new MIDP2CodenameOneCommand(current, Command.BACK, iter + 1);
        } else {
            if(iter == 0) {
                currentCommands[iter] = new MIDP2CodenameOneCommand(current, Command.OK, iter + 1);
            } else {
                currentCommands[iter] = new MIDP2CodenameOneCommand(current, iter + 1);
            }
        }
        addCommand(currentCommands[iter]);
    }
}
 
Example #4
Source File: CommentDetailsView.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == backCommand) {
        commentBackListener.backCommanded(false);
    }
    else if (command == replyCommand) {
        // Require logged-in user to access the Reply view
        if (!session.isLoggedIn()) {
            showLoginRequiredMessage();
            return;
        }
        showReplyView();
    }
    else if (command == loginCommand) {
        showLoginView();
    }
    else if (command == logoutCommand) {
        session.setLoggedOut();
        setupCommands();
    }
}
 
Example #5
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
public void editString(Component cmp, int maxSize, int constraint, String text, int keyCode) {
    UIManager m = UIManager.getInstance();
    CONFIRM_COMMAND = new Command(m.localize("ok", "OK"), Command.OK, 1);
    CANCEL_COMMAND = new Command(m.localize("cancel", "Cancel"), Command.CANCEL, 2);
    if(mid.getAppProperty("forceBackCommand") != null) {
        canvas.addCommand(MIDP_BACK_COMMAND);
    }
    currentTextBox = new TextBox("", "", maxSize, TextArea.ANY);
    currentTextBox.setCommandListener((CommandListener)canvas);
    currentTextBox.addCommand(CONFIRM_COMMAND);
    currentTextBox.addCommand(CANCEL_COMMAND);
    currentTextComponent = cmp;
    currentTextBox.setMaxSize(maxSize);
    currentTextBox.setString(text);
    currentTextBox.setConstraints(constraint);
    display.setCurrent(currentTextBox);
    ((C)canvas).setDone(false);
    Display.getInstance().invokeAndBlock(((C)canvas));
}
 
Example #6
Source File: LinksView.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == backCommand) {
        // Going back equals going back to the first view (popular page)
        abortPendingOperations();
        categoryListener.categorySelected(null);
    }
    else if (command == exitCommand) {
        Main.getInstance().onExitCommanded();
    }
    else if (command == categoryCommand) {
        showCategoryView();
    }
    else if (command == refreshCommand) {
        refresh();
    }
    else if (command == aboutCommand) {
        showAboutView();
    }
    else if (command == loginCommand) {
        showLoginView();
    }
    else if (command == logoutCommand) {
        session.setLoggedOut();
        setupCommands();
    }
}
 
Example #7
Source File: SuspendResumeUI.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Shows alert notifying user of system suspend.
 * @param token security token for accessing restricted API
 */
static synchronized void showSuspendAlert(final SecurityToken token) {
    if (null == suspendAlert && AlertTimer.shouldShow()) {
        String title = Resource.getString(
            ResourceConstants.SR_SUSPEND_ALERT_TITLE, null);
        String message = Resource.getString(
            ResourceConstants.SR_SUSPEND_ALERT_MSG, null);

        AlertTimer.start();

        CommandListener ignoring = new CommandListener() {
            public void commandAction(Command c, Displayable d) {}
        };

        suspendAlert = new SystemAlert(getDisp(token), title,
            message, null, AlertType.WARNING);
        suspendAlert.setCommandListener(ignoring);

        suspendAlert.runInNewThread();
    }
}
 
Example #8
Source File: AudioCanvas.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Implemented CommandListener method.
 */
public void commandAction(Command cmd, Displayable d) {
    if (cmd == backCommand) {
        if (infoMode) {
            infoMode = false;
            addCommand(infoCommand);
            repaint();
        } else {
            Display.getDisplay(midlet).setCurrent(returnScreen);
            pool.closeAllPlayers();
        }
        
    } else if (cmd == infoCommand) {
        infoMode = true;
        removeCommand(infoCommand);
        repaint();
    }
}
 
Example #9
Source File: VideoSourceSelector.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public void commandAction(Command cmd, Displayable d) {
    if (cmd == cmdOK) {
        String url = tf.getString();
        commitSelection(url);
    } else {
        Display.getDisplay(midlet).setCurrent(VideoSourceSelector.this);
    }
}
 
Example #10
Source File: AudioRecorder.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
protected void startApp() throws MIDletStateChangeException {
	this.recordButton = new StringItem(null, "Start", Item.BUTTON);
	Command toggleRecordingCMD = new Command("Click", Command.ITEM, 1);
	this.recordButton.addCommand(toggleRecordingCMD);
	this.recordButton.setDefaultCommand(toggleRecordingCMD);
	this.recordButton.setItemCommandListener(this);

	this.form = new Form(null, new Item[] {
			new StringItem(null, "Audio Recorder"), this.recordButton });

	this.display = Display.getDisplay(this);
	this.display.setCurrent(this.form);
}
 
Example #11
Source File: LoginView.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == backCommand) {
        backListener.backCommanded();
    } else if (command == submitCommand) {
        submitLogin();
    }
}
 
Example #12
Source File: CommentDetailsView.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Show the 'Reply' view (a full-screen TextBox).
 */
private void showReplyView() {
    final Command cancelCommand = new Command("Cancel", Command.BACK, 0);
    final Command sendCommand = new Command("Send", Command.OK, 0);

    replyView = new TextBox("Reply", null, 2000, TextField.ANY);
    replyView.addCommand(cancelCommand);
    replyView.addCommand(sendCommand);

    replyView.setCommandListener(new CommandListener() {
        public void commandAction(Command command, Displayable d) {
            // Cancel and return back to previous view
            if (command == cancelCommand) {
                setDisplay(self);
            }
            // Submit command
            else if (command == sendCommand) {
                String modhash = session.getModhash();
                replyOperation = new CommentPostOperation(
                    item.getName(),
                    replyView.getString(),
                    modhash,
                    (PostCommentListener) self
                );
                replyOperation.start();
            }
        }
    });
    setDisplay(replyView);
}
 
Example #13
Source File: GAFAControl.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see CommandListener#commandAction(Command, Displayable)
 */
public void commandAction(Command command, Displayable displayable) {
	if (displayable == myCanvas) {
		if (command == myCanvas.getExitCommand()) {
			exitMidlet();
		}
	}
}
 
Example #14
Source File: VideoSourceSelector.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public void commandAction(Command cmd, Displayable d) {
    if (cmd == SELECT_COMMAND) {
        int selection = getSelectedIndex();
        if (selection == 0) { // URL source selected
            Display.getDisplay(midlet).setCurrent(urlForm);
        } else if (selection == 1) { // JAR source selected
            // File name returned by the MediaFactory refers to the
            // "Video-Clip" application property...
            String videoFile = MediaFactory.getDefaultVideo().getFile();
            commitSelection(videoFile);
        }
    } else if (cmd == backCommand) {
        Display.getDisplay(midlet).setCurrent(returnList);
    }
}
 
Example #15
Source File: CommandActionEvent.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
public static Event getInstance(CommandListener listener, Command command, Displayable displayable) {
	CommandActionEvent instance = recycled.pop();

	if (instance == null) {
		instance = new CommandActionEvent();
	}

	instance.listener = listener;
	instance.command = command;
	instance.displayable = displayable;

	return instance;
}
 
Example #16
Source File: CommandActionEvent.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
public static Event getInstance(ItemCommandListener itemlistener, Command command, Item item) {
	CommandActionEvent instance = recycled.pop();

	if (instance == null) {
		instance = new CommandActionEvent();
	}

	instance.itemlistener = itemlistener;
	instance.command = command;
	instance.item = item;

	return instance;
}
 
Example #17
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void commandAction(Command c, Displayable d) {
    if (d == currentTextBox) {
        display.setCurrent(canvas);
        if (c == CONFIRM_COMMAND) {
            // confirm
            String text = currentTextBox.getString();
            getCurrentForm().setVisible(true);
            Display.getInstance().onEditingComplete(currentTextComponent, text);
        }

        currentTextBox = null;
        ((C)canvas).setDone(true);
    } else {
        if(c == MIDP_BACK_COMMAND) {
            GameCanvasImplementation.this.keyPressed(backSK);
            GameCanvasImplementation.this.keyReleased(backSK);
            return;
        }
        if(c instanceof MIDP2CodenameOneCommand) {
            final com.codename1.ui.Command cmd = ((MIDP2CodenameOneCommand)c).internal;
            Display.getInstance().callSerially(new Runnable() {
                public void run() {
                    Display.getInstance().getCurrent().dispatchCommand(cmd, new ActionEvent(cmd));
                }
            });
        }
    }
}
 
Example #18
Source File: MicroActivity.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
	if (current != null) {
		menu.clear();
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.midlet_displayable, menu);
		if (current instanceof Canvas) {
			SubMenu group = menu.getItem(0).getSubMenu();
			if (actionBarEnabled) {
				inflater.inflate(R.menu.midlet_canvas_no_keys2, menu);
			} else {
				inflater.inflate(R.menu.midlet_canvas_no_keys, group);
			}
			VirtualKeyboard vk = ContextHolder.getVk();
			if (vk instanceof FixedKeyboard) {
				inflater.inflate(R.menu.midlet_canvas_fixed, group);
			} else if (vk != null) {
				inflater.inflate(R.menu.midlet_canvas, group);
			}
		}
		for (Command cmd : current.getCommands()) {
			menu.add(Menu.NONE, cmd.hashCode(), Menu.NONE, cmd.getAndroidLabel());
		}
	}

	return super.onPrepareOptionsMenu(menu);
}
 
Example #19
Source File: AboutView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == backCommand) {
        backListener.backCommanded();
    }
}
 
Example #20
Source File: AudioRecorder.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command c, Displayable d) {
}
 
Example #21
Source File: AudioRecorder.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command command, Item item) {
	if (item == this.recordButton) {
		this.toggleRecorderStatus();
	}
}
 
Example #22
Source File: CategorySelectView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command command, Displayable displayable) {
    if (command == backCommand) {
        backListener.backCommanded();
    }
}
 
Example #23
Source File: LoginView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command command, Item item) {
    commandAction(command, (Displayable) null);
}
 
Example #24
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public MIDP2CodenameOneCommand(com.codename1.ui.Command c, int offset) {
    super(c.getCommandName(), Command.SCREEN, offset);
    internal = c;
}
 
Example #25
Source File: SupportForm.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public void commandAction(Command cmd, Displayable d) {
    Display.getDisplay(midlet).setCurrent(medialist);
}
 
Example #26
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public MIDP2CodenameOneCommand(com.codename1.ui.Command c, int type, int offset) {
    super(c.getCommandName(), type, offset);
    internal = c;
}
 
Example #27
Source File: GAFAView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public Command getExitCommand() {
	return exitCommand;
}
 
Example #28
Source File: GAFAView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
public GAFAView(CommandListener commandListener, Display display) {
	setTitle("GAFA APIs");
	myRectPosX = myGestureZonePosX = 5;
	myRectPosY = myGestureZonePosY = 5;
	myRectWidth = (short) (myGestureZoneWidth = 32);
	myRectHeight = (short) (myGestureZoneHeight = 32);
	mySquares = new Vector(10, 4);

	// Add commands
	exitCommand = new Command("Exit", Command.EXIT, 1);
	addCommand(exitCommand);
	setCommandListener(commandListener);

	// Create the first GestureInteractiveZone. The GestureInteractiveZone
	// class is used to define an
	// area of the screen that reacts to a set of specified gestures.
	// The parameter GESTURE_ALL means that we want events for all gestures.
	gizCanvas = new GestureInteractiveZone(
			GestureInteractiveZone.GESTURE_ALL);
	// Create the second interactive zone handling the DRAG gestures on the
	// rectangle area
	gizRectangle = new GestureInteractiveZone(
			GestureInteractiveZone.GESTURE_DRAG);
	gizRectangle.setRectangle(myRectPosX, myRectPosY, myRectWidth,
			myRectHeight);

	// Register the GestureInteractiveZones for myCanvas.
	if (GestureRegistrationManager.register(this, gizCanvas))
		System.out.println("Gestures for canvas added");
	if (GestureRegistrationManager.register(this, gizRectangle))
		System.out.println("Gestures for rect added");

	// Set this listener to a canvas or custom item
	GestureRegistrationManager.setListener(this, this);

	/*
	 * // Get system properties for fps and pps defaultFps = (short)
	 * Integer.parseInt(System
	 * .getProperty("com.nokia.mid.ui.frameanimator.fps")); defaultPps =
	 * (short) Integer.parseInt(System
	 * .getProperty("com.nokia.mid.ui.frameanimator.pps"));
	 */
	// Use default values
	maxFps = 0;
	maxPps = 0;

	// Create the frame animator for the rectangle
	rectAnimator = new FrameAnimator();
	// Initialize the frame animator
	rectAnimator.register(myRectPosX, myRectPosY, maxFps, maxPps,
			(FrameAnimatorListener) this);

	// Initialize the drag & drop counter used to store missing frame
	// increments
	dragCounterX = 0;
	dragCounterY = 0;
}
 
Example #29
Source File: CommandAccess.java    From pluotsorbet with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the label of the given Command.
 *
 * @param c The Command to retrieve the label of
 * @return String The label of the Command
 */
String getLabel(Command c);
 
Example #30
Source File: CommandAccess.java    From pluotsorbet with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the type of the given Command.
 *
 * @param c The Command to retrieve the type of
 * @return int The type of the Command
 */
int    getType(Command c);