DrawLine.java Source code

Java tutorial

Introduction

Here is the source code for DrawLine.java

Source

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DrawLine {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.open();

        GC gc = new GC(shell);

        gc.drawLine(0, 0, 19, 19);
        gc.drawLine(19, 0, 0, 19);

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

        display.dispose();
    }
}