Package gui

Source Code of gui.MultiplayerSelection

package gui;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import main.BTMIDlet;

/**
*
* @author TeXteR
*/
public class MultiplayerSelection extends List implements CommandListener {

    private final Command backCommand;
    private ClientConnection clientConnection;
    private ServerConection serverConection;
    private BTMIDlet bTMIDlet;

    public MultiplayerSelection(BTMIDlet bTMIDlet) {
        super("Multiplayer", IMPLICIT);

        this.bTMIDlet = bTMIDlet;

        backCommand = new Command("Back", Command.BACK, 1);

        append("Start server", null);
        append("Connect to server", null);

        addCommand(backCommand);
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        int selectedIndex = getSelectedIndex();

        if (c.equals(backCommand)) {
            bTMIDlet.showMenu();
        } else if (c.getCommandType() == Command.SCREEN) {
            if(getString(selectedIndex).equals("Connect to server")) {
                clientConnection = new ClientConnection(bTMIDlet);
            } else if(getString(selectedIndex).equals("Start server")) {
                serverConection = new ServerConection(bTMIDlet);
            }
        }
    }
}
TOP

Related Classes of gui.MultiplayerSelection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.