2014-02-05 23 views
1

SWT表格標題中的&符號不會顯示,是否有已知的解決方法?SWT表格標題中的&符號解決方法

我在我的應用程序中顯示的符號,我正在尋找一個解決辦法...

https://bugs.eclipse.org/bugs/show_bug.cgi?id=154904

如果你不想閱讀完整的atricle只要按照這個例子

public class TableWidget { 

    Display d; 

    Shell s; 

    TableWidget() { 
    d = new Display(); 
    s = new Shell(d); 

    s.setSize(250, 200); 

    s.setText("A Table Shell Example"); 
    s.setLayout(new FillLayout()); 

    Table t = new Table(s, SWT.BORDER); 

    TableColumn tc1 = new TableColumn(t, SWT.CENTER); 
    TableColumn tc2 = new TableColumn(t, SWT.CENTER); 
    TableColumn tc3 = new TableColumn(t, SWT.CENTER); 
    tc1.setText("First&&Name"); //THESE ampersands won't be shown 
    tc2.setText("Last & Name"); //and HERE 
    tc3.setText("Address"); 
    tc1.setWidth(70); 
    tc2.setWidth(70); 
    tc3.setWidth(80); 
    t.setHeaderVisible(true); 

    TableItem item1 = new TableItem(t, SWT.NONE); 
    item1.setText(new String[] { "Tim", "Hatton", "Kentucky" }); 
    TableItem item2 = new TableItem(t, SWT.NONE); 
    item2.setText(new String[] { "Caitlyn", "Warner", "Ohio" }); 
    TableItem item3 = new TableItem(t, SWT.NONE); 
    item3.setText(new String[] { "Reese", "Miller", "Ohio" }); 

    s.open(); 
    while (!s.isDisposed()) { 
     if (!d.readAndDispatch()) 
     d.sleep(); 
    } 
    d.dispose(); 
    } 

    public static void main(String[] argv) { 
    new TableWidget(); 
    } 

} 

是的,當然,「\ u0026」將無法工作,以及 - 我真的不期待一個解決方案,但也許有人比我更聰明...

+0

那麼,使用'&&'而不是'&'然後是什麼問題?對我來說工作得很好。或者這是特定於某個版本的Windows/SWT? – Baz

+1

您只需使用SWT版本> = 3.7.2即可擺脫此錯誤! – bobbel

回答

2

好吧,以後版本可能會解決問題,但我們有'老式'的客戶,我們甚至使用Eclipse 3.4(!!)產生java 1.6的代碼

但我找到了一個替代方法,就像我要求的....如果你用全寬符號(\ uFF06)替換任何&符號(\ u0026),你擺脫了這個問題....

我發現解決方案http://en.wikipedia.org/wiki/Ampersand,他們顯示替代符號!

對不起,我在這裏創造了這樣的混亂!感謝您的支持......

+0

最後一個很好的解決方法。感謝分享! – bobbel