views:

38

answers:

0
import javax.microedition.lcdui.Display;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class ExpenseManager extends UiApplication {
    public static void main(String[] args) {
        ExpenseManager theApp = new ExpenseManager();
        theApp.enterEventDispatcher();
    }

    public ExpenseManager() {
        pushScreen(new GeneralExpenseViewScreen());
    }
}

final class GeneralExpenseViewScreen extends MainScreen {
    public GeneralExpenseViewScreen() {
        super();
        LabelField title = new LabelField("TeamMate TEC | Expenses",
                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);

        Background bg = BackgroundFactory.createSolidBackground(0xBDBDDB);
        setBackground(bg);

        HorizontalFieldManager headerAreaManager = new HorizontalFieldManager();
        HorizontalFieldManager filterAreaManager = new HorizontalFieldManager() {
            protected void sublayout(int width, int height) {
                setExtent(360, 95);
            }
        };
        HorizontalFieldManager expenseListAreaManager = new HorizontalFieldManager() {
            protected void sublayout(int width, int height) {
                setExtent(360, 200);
            }
        };      
        HorizontalFieldManager totalAreaManager = new HorizontalFieldManager() {
            protected void sublayout(int width, int height) {
                setExtent(360, 45);
            }
        };
        HorizontalFieldManager addNewAreaManager = new HorizontalFieldManager() {
            protected void sublayout(int width, int height) {
                setExtent(360, 103);
            }
        };

        filterAreaManager.setBackground(bg);
        expenseListAreaManager.setBackground(bg);
        totalAreaManager.setBackground(bg);
        addNewAreaManager.setBackground(bg);

        add(headerAreaManager);
        add(filterAreaManager);
        add(expenseListAreaManager);
        add(totalAreaManager);
        add(addNewAreaManager);

        /**Begin form layouts**/

        Bitmap headerImage = Bitmap.getBitmapResource("sergioheader.png");
        BitmapField header = new BitmapField(headerImage);
        headerAreaManager.add(header);

    }

    public boolean onClose() {
        Dialog.alert("AH!");
        System.exit(0);
        return true;
    }
}

Why is this error popping up whenever I click anywhere on the form? Remember I don't have any code that does anything except these field managers that are going to handle layouts. What gives?