TextScreen.java

/*
 * Copyright @ 2012 Nokia Corporation. All rights reserved. Nokia and Nokia
 * Connecting People are registered trademarks of Nokia Corporation. Oracle and
 * Java are trademarks or registered trademarks of Oracle and/or its affiliates.
 * Other product and company names mentioned herein may be trademarks or trade
 * names of their respective owners. See LICENSE.TXT for license information.
 */
package com.nokia.example.btsppecho;

import javax.microedition.lcdui.*;

// A closeable screen for displaying text.
class TextScreen
        extends Form
        implements CommandListener {

    private final MIDletApplication midlet;
    private final Displayable next;

    TextScreen(MIDletApplication midlet,
            Displayable next,
            String title,
            String text,
            String closeLabel) {
        super(title);
        this.midlet = midlet;
        this.next = next;
        append(text);
        addCommand(new Command(closeLabel, Command.BACK, 1));
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        // The application code only adds a 'close' command.
        midlet.textScreenClosed(next);
    }
}