Cannot Insert Tab spaces ("\t") in J2ME String

922 Views Asked by At

I have a String

str = "Hello\tWorld";

When I print the string in a J2ME application, it results:

"HelloWorld" instead of "Hello<tab space>World"

When the below sample code is run, the textfield does not display the tab space but it only display "HelloWorld" without tab space.

Sample code:

public class MyApp extends MIDlet {

    private Display display;
    private Form frmMain;

    public MyApp() {
        display = Display.getDisplay(this);
        frmMain = new Form("Hello");
    }


    protected void startApp() throws MIDletStateChangeException {
        TextField txt = new TextField("Text", "", 200, TextField.ANY);
        txt.setString("Hello\tWorld");
        frmMain.append(txt);

        display.setCurrent(frmMain);
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
        destroyApp(unconditional);
        notifyDestroyed();
    }
}
0

There are 0 best solutions below