I would like to add a image to a button in my table. The table is displayed in my main GUI. I am using a TableViewer to display the table.
private void createTableViewer(Composite parent) {
viewer = new AplotDataTableViewer(parent, SWT.BORDER|SWT.V_SCROLL|SWT.FULL_SELECTION);
viewer.setInput(AplotDataModel.getInstance().getArrayData());
}
AplotDataTableViewer is a separate class. The constructor for AplotDataTableViewer takes in the composite and Style.
So when I try to add a image in the AplotDataTableViewer class, it gives me a error on the Display variable. I think it is because Image requires a Display.
Image image = new Image(display, String);
I am not sure what it is needing for display? If it is needing the display from the main GUI, how do I get that?
You can just use:
Or use
Display.getCurrent()instead.For more details, here is a good tutorial about SWT
Images:Taking a look at SWT Images