java – How to keep @ character in SWT menu item text


I built a Java application using SWT and JFace (on Windows). Here I would like to put an email address as text in a menu item and use the following action class:

private class MyAction extends Action {
    public MyAction() {
        super("[email protected]");
    }

    @Override
    public void run() {
        // code to execute
    }
}

and of course:

protected MenuManager createMenuManager() {
    MenuManager menuBar = new MenuManager();
    MenuManager myMenu = new MenuManager("Menu");
    myMenu.add(new MyAction());
    menuBar.add(myMenu);
    return menuBar;
}

What confuses me a bit is that when the menu is displayed, the “at” character is missing and a space is shown in its place instead.

Can I somehow keep the @ character?

I’ve already tried putting a double backslash in front of the @ character or replacing the @ character with the Unicode notation \u0040 – neither of which helped.



Source link

Leave a Comment