FileDocCategorySizeDatePackage
TextBoxMIDlet.javaAPI DocExample2089Sun Oct 07 19:27:46 BST 2001ora.ch4

TextBoxMIDlet

public class TextBoxMIDlet extends javax.microedition.midlet.MIDlet

Fields Summary
private static final int
MAX_TEXT_SIZE
protected javax.microedition.lcdui.TextBox
textBox
protected javax.microedition.lcdui.Display
display
protected boolean
started
Constructors Summary
Methods Summary
protected voiddestroyApp(boolean unconditional)

    
protected voidpauseApp()

    
protected voidstartApp()

    
       
        if (!started) {
            // First time through - initialize            
            // Get the text to be displayed
            String str = null;
            try {
                InputStream is = getClass().getResourceAsStream("resources/text.txt");
                InputStreamReader r = new InputStreamReader(is);
                char[] buffer = new char[32];
                StringBuffer sb = new StringBuffer();
                int count;
                while ((count = r.read(buffer, 0, buffer.length)) > -1) {
                    sb.append(buffer, 0, count);
                }
                str = sb.toString();
            } catch (IOException ex) {
                str = "Failed to load text";
            }
            
            // Create the TextBox
            textBox = new TextBox("TextBox Example", str, 
                                MAX_TEXT_SIZE, TextField.ANY);
            
            // Create a ticker and install it
            Ticker ticker = new Ticker("This is a ticker...");
            textBox.setTicker(ticker);
            
            // Install the TextBox as the current screen
            display = Display.getDisplay(this);            
            display.setCurrent(textBox);

            started = true;
        }