Search code examples
blackberrytextfieldhint

TextField - show hint before user starts typing text


I am developing an Blackberry application. I want to show a hint text in TextField before user starts typing.when user starts typing it should disappear and when there are 0 characters in TextField it should show up.Has anybody implemented this yet?then please share.


Solution

  • here is the implementation within paint() method

    String test = super.getText();
            if ( test == null || test.length() < 1 ) {
                graphics.setColor( 0x00a0a0a0 );
                graphics.drawText(hint, 0, 0);
            }
    

    and here is the source thanks to peter_strange http://supportforums.blackberry.com/t5/Java-Development/Prompt-hint-place-holder-text-on-a-Numeric-Password-edit-field/m-p/990817#M151704