javax.microedition.lcdui.Displayable Java Examples

The following examples show how to use javax.microedition.lcdui.Displayable. 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: 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 #2
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 #3
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 #4
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 #5
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
private void setCurrent(Displayable d) {
    if (display == null) {
        throw new IllegalStateException("First call Display.setDisplay(javax.microedition.lcdui.Display d) method");
    }

    if(!minimized) {
        if (d instanceof Canvas) {
            if(!disableFullScreen) {
                ((Canvas) d).setFullScreenMode(!com.codename1.ui.Display.getInstance().isNativeCommands());
            }
        }

        display.setCurrent(d);
    }
}
 
Example #6
Source File: MidletThread.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
static void destroyApp() {
	new Thread(() -> {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		Process.killProcess(Process.myPid());
	}, "ForceDestroyTimer").start();
	Displayable current = ContextHolder.getActivity().getCurrent();
	if (current instanceof Canvas) {
		Canvas canvas = (Canvas) current;
		int keyCode = Canvas.convertKeyCode(Canvas.KEY_END);
		Display.postEvent(CanvasEvent.getInstance(canvas, CanvasEvent.KEY_PRESSED, keyCode));
		Display.postEvent(CanvasEvent.getInstance(canvas, CanvasEvent.KEY_RELEASED, keyCode));
	}
	instance.handler.obtainMessage(DESTROY, 1).sendToTarget();
}
 
Example #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
Source File: AudioCanvas.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public AudioCanvas(MediaSamplerMIDlet midlet, Displayable returnScreen, int latency) {
    this.midlet = midlet;
    this.returnScreen = returnScreen;
    pool = new PlayerPool(midlet, latency);
    initSounds();
    // Init volume level of Players in pool
    pool.setVolumeLevel(midletVolume);
    addCommand(backCommand);
    addCommand(infoCommand);
    setCommandListener(this);
}
 
Example #16
Source File: SupportForm.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public SupportForm(MediaSamplerMIDlet midlet, Displayable medialist) {
    super("MM API support check");
    this.midlet = midlet;
    this.medialist = medialist;
    addCommand(backCmd);
    setCommandListener(this);
    init();
}
 
Example #17
Source File: TestHarness.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public void setScreenAndWait(Displayable s) {
    display.setCurrent(s);
    while (!(s.isShown() && (display.getCurrent() == s))) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            fail("INTERRUPTED");
            break;
        }
    }
}
 
Example #18
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 #19
Source File: LCDUIEvent.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a screen change event.
 *
 * @param parent parent Display of the Displayable
 * @param d The Displayable to change the current screen to
 *
 * @return initialized event
 */
static LCDUIEvent createScreenChangeEvent(
    DisplayEventConsumer parent, 
    Displayable d) {
    LCDUIEvent e = new LCDUIEvent(EventTypes.SCREEN_CHANGE_EVENT);
    e.display = parent;
    e.nextScreen = d;
    return e;
}
 
Example #20
Source File: ExtendedImage.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
public ExtendedImage(Image image) {
	this.image = image;
	this.width = Displayable.getVirtualWidth();
	this.height = Displayable.getVirtualHeight();
	this.buffer = Image.createTransparentImage(width, height);
	this.bufferGraphics = buffer.getGraphics();
}
 
Example #21
Source File: GameMap.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the DisplayAccess object for this Displayable.
 * @param c The Displayable to get the DisplayAccess for
 * @return DisplayAccess The DisplayAccess associated with the MIDlet
 */
public static DisplayAccess getDisplayAccess(Displayable c) {
    synchronized (lock) {
       if (c == displayable) {
            return displayAccess;
       } else {
            return null;
     }
    }
}
 
Example #22
Source File: BaseFormView.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
protected static void setDisplay(Displayable display) {
    Display.getDisplay(Main.getInstance()).setCurrent(display);
}
 
Example #23
Source File: MicroLoader.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
public void applyConfiguration() {
	try {
		boolean cxShowKeyboard = params.getBoolean(("ShowKeyboard"), true);

		// Apply configuration to the launching MIDlet
		if (cxShowKeyboard) {
			setVirtualKeyboard();
		} else {
			ContextHolder.setVk(null);
		}
		setProperties();

		int fontSizeSmall = params.getInt("FontSizeSmall", 18);
		int fontSizeMedium = params.getInt("FontSizeSmall", 18);
		int fontSizeLarge = params.getInt("FontSizeLarge", 26);
		boolean fontApplyDimensions = params.getBoolean("FontApplyDimensions", false);

		int screenWidth = params.getInt("ScreenWidth", 240);
		int screenHeight = params.getInt("ScreenHeight", 320);
		int screenBackgroundColor = params.getInt("ScreenBackgroundColor", 0xD0D0D0);
		int screenScaleRatio = params.getInt("ScreenScaleRatio", 100);
		boolean screenScaleToFit = params.getBoolean("ScreenScaleToFit", true);
		boolean screenKeepAspectRatio = params.getBoolean("ScreenKeepAspectRatio", true);
		boolean screenFilter = params.getBoolean("ScreenFilter", false);
		boolean immediateMode = params.getBoolean("ImmediateMode", false);
		boolean touchInput = params.getBoolean(("TouchInput"), true);
		boolean hwAcceleration = params.getBoolean("HwAcceleration", false);
		boolean parallel = params.getBoolean("ParallelRedrawScreen", false);
		boolean forceFullScreen = params.getBoolean("ForceFullscreen", false);
		boolean showFps = params.getBoolean("ShowFps", false);
		boolean limitFps = params.getBoolean("LimitFps", false);
		int fpsLimit = params.getInt("FpsLimit", 0);
		int layout = params.getInt("Layout", 0);

		Font.setSize(Font.SIZE_SMALL, fontSizeSmall);
		Font.setSize(Font.SIZE_MEDIUM, fontSizeMedium);
		Font.setSize(Font.SIZE_LARGE, fontSizeLarge);
		Font.setApplyDimensions(fontApplyDimensions);

		final String[] propLines = params.getString("SystemProperties", "").split("\n");
		for (String line : propLines) {
			String[] prop = line.split(":[ ]*", 2);
			if (prop.length == 2) {
				System.setProperty(prop[0], prop[1]);
			}
		}

		SparseIntArray intArray = KeyMapper.getArrayPref(params);
		Displayable.setVirtualSize(screenWidth, screenHeight);
		Canvas.setScale(screenScaleToFit, screenKeepAspectRatio, screenScaleRatio);
		Canvas.setFilterBitmap(screenFilter);
		EventQueue.setImmediate(immediateMode);
		Canvas.setHardwareAcceleration(hwAcceleration, parallel);
		Canvas.setBackgroundColor(screenBackgroundColor);
		Canvas.setKeyMapping(layout, intArray);
		Canvas.setHasTouchInput(touchInput);
		Canvas.setForceFullscreen(forceFullScreen);
		Canvas.setShowFps(showFps);
		Canvas.setLimitFps(limitFps, fpsLimit);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #24
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 #25
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @inheritDoc
 */
public void showNativeScreen(Object nativeFullScreenPeer) {
    display.setCurrent((Displayable)nativeFullScreenPeer);
}
 
Example #26
Source File: MicroActivity.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
public Displayable getCurrent() {
	return current;
}
 
Example #27
Source File: MicroActivity.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
public void setCurrent(Displayable displayable) {
	current = displayable;
	ViewHandler.postEvent(msgSetCurrent);
}
 
Example #28
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 #29
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 #30
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) {
}