⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectstockscreen.java

📁 手机程序股票购买售出的例子
💻 JAVA
字号:
import java.util.Vector;
import javax.microedition.lcdui.*;

public class SelectStockScreen extends StockScreen implements CommandListener
{
    private Command nextCommand = null;
    private Command backCommand = null;

    private ChoiceGroup _stockList = null;

    public SelectStockScreen(Controller controller)
    {
        super("Select Stock", controller);

        try
        {
            Vector stocks = _stockDB.getStocks();

            Item displayItem = showStockList(stocks);

            append(displayItem);

            super.generateButtons();

            this.setCommandListener( this);

        }
        catch (StockException se)
        {
            append(se.getMessage() );
        }
    }

    private Item showStockList(Vector stocks)
    {

        Stock currentStock = null;

        _stockList = new ChoiceGroup("Choose stock", ChoiceGroup.EXCLUSIVE);

        for ( int i = 0; i < stocks.size(); i++)
        {
            currentStock = (Stock) stocks.elementAt(i);
            _stockList.append( currentStock.getSymbol(), null );
        }

        return _stockList;
    }

    public void commandAction( Command c, Displayable d)
    {
        if ( c == backCommand)
        {
            _controller.lastScreen();
        }
        else
        {
            // get the selected item
            int selectedIndex = _stockList.getSelectedIndex();

            String selectedStock = _stockList.getString( selectedIndex);

            // move on to the how many screen
            SellStockScreen sellStockScreen = new SellStockScreen(_controller, selectedStock);

            _controller.nextScreen( sellStockScreen);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -