www.pudn.com > StockManager.rar > StockScreen.java


 
import javax.microedition.lcdui.*; 
 
public class StockScreen extends Form 
{ 
    private StringItem _symbolField = null; 
    private StringItem _numSharesField = null; 
 
    protected TextField _symbolEntry = null; 
    protected TextField _numEntry = null; 
 
    protected Command nextCommand = null; 
    protected Command backCommand = null; 
 
    protected Controller _controller = null; 
    protected StockDatabase _stockDB = null; 
 
    public StockScreen(String title, Controller controller) 
    { 
        super(title); 
 
        _controller = controller; 
        _stockDB = controller.getStockDatabase(); 
    } 
 
    public void displayScreen(String symbol, int numShares) 
    { 
        _symbolField = new StringItem("Stock Symbol: ", symbol); 
        _numSharesField = new StringItem("Num Shares: ", ""+ numShares); 
 
        append(_symbolField); 
        append(_numSharesField); 
 
        generateButtons(); 
    } 
 
    public void displayScreen() 
    { 
        _symbolEntry = new TextField("Enter Stock Symbol", "", 6, TextField.ANY); 
        _numEntry = new TextField("Enter Num Shares", "", 10, TextField.NUMERIC); 
 
        append(_symbolEntry); 
        append(_numEntry); 
 
        generateButtons(); 
    } 
 
    public void generateButtons() 
    { 
        this.nextCommand = new Command("Next", Command.SCREEN, 1); 
        this.backCommand = new Command("Back", Command.BACK, 1); 
 
        this.addCommand(backCommand); 
        this.addCommand(nextCommand); 
    } 
}