Mega Code Archive

 
Categories / Java Tutorial / SWT 2D Graphics
 

Draw line

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();   } }