2010-01-25 118 views
2

有沒有辦法在視圖中同時使用SWT buuton和圖像和文本?我已經嘗試在SWT中嵌入Swing,視圖看起來完全如我所願,但是當有一個操作正在進行時,此視圖在加載完成之前不會加載。這使我的觀點看起來不穩定。請幫忙。SWT按鈕上的文本和圖像

+0

我試圖實現相同的任何解決方案嗎? – marcolopes 2012-10-11 07:03:28

回答

1

你在使用什麼操作系統?在Windows XP/Vista/Windows 7上,GTK +和OSX可以設置文本和圖像。例如。

public class ButtonView extends ViewPart 
{ 
    private Button m_button; 

    public void createPartControl(Composite parent) 
    { 
     m_button = new Button(parent, SWT.NONE); 
     m_button.setText("My Button"); 
     m_button.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); 
    } 

    public void setFocus() 
    { 
     m_button.setFocus(); 
    } 
} 
+0

是的,但圖像與文字重疊。 – marcolopes 2012-09-03 00:36:02