×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2009
    Location
    Brazil
    Posts
    8

    Exclamation NullPointerException On a Calling a Function

    Hello,
    I'm building a program that gets the value of a TextField, concatenate with some other Strings and then display them on a TextBox when the ScreenCommand is clicked, the problem is that it's calling a NullPointerException. My code is like this(of course it has a lot more stuff):
    Code:
    /* .... */
            } else if (command == submitCommand) {
                FirstPart();
                // write pre-action user code here
                switchDisplayable(null, getTextBox3());
                // write post-action user code here
            }
    /* .... */
    
    public void FirstPart() {
        String test = "";
        test = "tst" + textField.getString() + "test";
        textBox3.setString(test);
    }
    /* .... */
    And I get this when I click the menu:
    Code:
    TRACE: <at java.lang.NullPointerException:   0>, Exception caught in Display class
    java.lang.NullPointerException:   0
            at mp.releaser.MPReleaser.commandAction(MPReleaser.java:130)
            at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46
            at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74
            at com.sun.midp.chameleon.layers.SoftButtonLayer.commandSelected(), bci=11
            at com.sun.midp.chameleon.layers.MenuLayer.pointerInput(), bci=188
            at com.sun.midp.chameleon.CWindow.pointerInput(), bci=88
            at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handlePointerEvent(), bci=19
            at com.sun.midp.lcdui.DisplayEventListener.process(), bci=296
            at com.sun.midp.events.EventQueue.run(), bci=179
            at java.lang.Thread.run(Thread.java:680)
    What should I do to correct this?

    Best Regards,
    Nathan Paulino Campos

    PS: Netbeans should have a NullPointerException corrector tool
    Last edited by nathanpc; 2011-02-03 at 22:42.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: NullPointerException On a Calling a Function

    Which is line 535?

    I'd guess that either textField or textBox3 is null.

    Graham.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Location
    Brazil
    Posts
    8

    Re: NullPointerException On a Calling a Function

    I've already corrected that null line, but see the edits on the error.

    PS:
    Line 130 Is the last one:
    Code:
    String test = null;
            test = "tst" + textField.getString() + "test";
            textBox3.setString(test);

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: NullPointerException On a Calling a Function

    If line 130 is "textBox3.setString(test)", then textBox3 is null.

    Graham.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Location
    Brazil
    Posts
    8

    Re: NullPointerException On a Calling a Function

    What I should do to correct?

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: NullPointerException On a Calling a Function

    There is a tutorial here, on creating objects.

    Graham.

Similar Threads

  1. Replies: 1
    Last Post: 2010-12-09, 12:53
  2. Replies: 7
    Last Post: 2009-05-15, 11:39
  3. Calling library function
    By iyadoo in forum Symbian
    Replies: 1
    Last Post: 2008-02-22, 12:29
  4. NullPointerException on my split function
    By alicegue in forum Mobile Java General
    Replies: 2
    Last Post: 2005-09-21, 06:51
  5. Calling a function?
    By techno2003 in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-08-06, 12:15

Posting Permissions

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