×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    12

    addCommand throws null pointer

    The code:

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class About extends Canvas implements CommandListener
    {
    private final Bartender parent;
    // private Bartender midlet;
    private Form fmAbout;
    private Ticker tiAbout;
    private Command cmdOK;
    public About (Bartender parent)
    {this.parent = parent; }
    synchronized void start()
    {
    cmdOK = new Command("OK", Command.OK, 1);

    //////// this part gives null pointer !!!!! /////////
    fmAbout.addCommand(cmdOK);
    ////////////////////////////////////////////////////////

    // fmAbout.setCommandListener(this);

    Display.getDisplay(parent).setCurrent(fmAbout);
    }
    public void paint(Graphics g) {}
    public void commandAction(Command c, Displayable d)
    {
    if (c == cmdOK)
    {
    Display.getDisplay(parent).setCurrent(parent.canvas2);
    }}}

    It's definately parent and midlet stuff (but I can't figure out how to use midlet instead of parent - I need to have it)

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    I don't see that you're new-ing up fmAbout anywhere in the code, so probably fmAbout is null.

    shmoove

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    12
    fmAbout is perfectly fine. I added ticker and text - they worked just fine.
    This problem might be because of I use FullCanvas in other classes, and because of defining main class Bartender as parent not midlet...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×