Sanyifejű
Sanyifejű

Reputation: 2740

How to put margin between icon and text of an SWT Button?

I would like to have some margin between text and icon (image) on my Button.

That's what I have:

Button btn = new Button(grpInventar, SWT.NONE);
GridData gd_btn = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_btn.widthHint = 154;
btn.setLayoutData(gd_btn);
btn.setAlignment(SWT.LEFT);
btn.setImage(this.getImageByLocation(Application.getIconLocByInventoryClass(Whateverimage.class )));                                                    
btn.setText("Text");

I would love to add something like:

btn.setMarginBetweenTextIcon(12)

Is there something out there?

Upvotes: 0

Views: 222

Answers (1)

greg-449
greg-449

Reputation: 111217

There is no support for this in SWT. You could use an image with empty pixels on the right or text with leading spaces.

Also note that not all platforms support having an image and text in a button.

Upvotes: 1

Related Questions