user3104682
user3104682

Reputation: 57

Drawing a label on canvas top right corner

How can i draw a label on the top right corner of the canvas and making it stay there as long as i re-size the window?

I tried setting the SWT.RIGHT_TO_LEFT style on the canvas constructor but i don't want the whole canvas to change it's direction.

Thanks in advance.

Upvotes: 1

Views: 916

Answers (1)

greg-449
greg-449

Reputation: 111217

You need to set a Layout on the Canvas and position the label using the layout.

For example:

canvas.setLayout(new GridLayout());

...

label.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false));

Do you actually need to use Canvas? If you are only using controls as children then Composite would be more usually.

Upvotes: 2

Related Questions