Example usage for org.eclipse.swt.widgets Canvas setLocation

List of usage examples for org.eclipse.swt.widgets Canvas setLocation

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Canvas setLocation.

Prototype

public void setLocation(int x, int y) 

Source Link

Document

Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell.

Usage

From source file:DrawExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Drawing Example");

    Canvas canvas = new Canvas(shell, SWT.NONE);
    canvas.setSize(150, 150);//from  www .  j  av  a  2s . c o  m
    canvas.setLocation(20, 20);
    shell.open();
    shell.setSize(200, 220);

    GC gc = new GC(canvas);
    gc.drawRectangle(10, 10, 40, 45);
    gc.drawOval(65, 10, 30, 35);
    gc.drawLine(130, 10, 90, 80);
    gc.drawPolygon(new int[] { 20, 70, 45, 90, 70, 70 });
    gc.drawPolyline(new int[] { 10, 120, 70, 100, 100, 130, 130, 75 });
    gc.dispose();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}