Search code examples
javaeclipsesdkeclipse-rcprcp

group design in eclipse 4 RCP


I want to add an image and a label in a group on a composite by using eclipse 4 RCP. Example image is like below. How can I do this?

example image

My example code is below:

Group group_incom = new Group(dynamicDataComp, SWT.NONE);
    group_incom.setLayout(new GridLayout(2,true));
    group_incom.setText("Incom. Msg.");
    Label lbl_incomMsg = toolkit.createLabel(group_incom, "# of Incoming Messages : ", SWT.NONE);
    Image img = new Image(lbl_incomMsg.getDisplay(), "<path>");
    lbl_incomMsg.setImage(img);
    lbl_incomMsg.setLocation(15, 15);
    lbl_incomMsg.pack();

The problem is, I can see the image but I can not see the label text.


Solution

  • Label can display text or an image, it won't display both. So either use two Label controls one for the image and one for the text or use CLabel which can display both.