Kanupriya
Kanupriya

Reputation: 21

Text and Image on SWT Button

Is there a way to have a SWT buuton with both image and text in a view? I have tried embedding Swings in SWT and the view looks exactly as I want, but when there is an operation going on, this view doesnot load till it gets over. This makes my perspective look unstable. Please help.

Upvotes: 2

Views: 1800

Answers (1)

Kire Haglin
Kire Haglin

Reputation: 7079

What OS are you using? On Windows XP/Vista/Windows 7, GTK+ and OSX you can just set the text and the image. E.g.

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();
    }
}

Upvotes: 1

Related Questions