无法在J2ME字符串中插入制表符空格(“\ t”)

时间:2012-05-21 12:37:34

标签: java java-me midp lcdui

我有一个字符串

str = "Hello\tWorld";

当我在J2ME应用程序中打印字符串时,结果是:

"HelloWorld"代替"Hello<tab space>World"

运行以下示例代码时,文本字段不显示选项卡空间,但只显示没有制表符空间的“HelloWorld”。

示例代码:

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 个答案:

没有答案