Created
September 3, 2012 10:25
-
-
Save davorb/3608395 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.events.PaintEvent; | |
import org.eclipse.swt.events.PaintListener; | |
import org.eclipse.swt.graphics.Font; | |
import org.eclipse.swt.widgets.Display; | |
import org.eclipse.swt.widgets.Shell; | |
public class SwtApp { | |
public SwtApp(final Display display) { | |
final Shell shell = new Shell(display); | |
shell.addPaintListener(new PaintListener(){ | |
public void paintControl(PaintEvent e){ | |
e.gc.setBackground(display.getSystemColor(SWT.COLOR_RED)); | |
e.gc.fillOval(10,10,100,100); | |
Font font = new Font(display,"Arial",22,SWT.BOLD); | |
e.gc.setFont(font); | |
e.gc.drawText("Hello",1,30, SWT.DRAW_TRANSPARENT); | |
font.dispose(); | |
e.gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); | |
e.gc.fillOval(40,40,100,100); | |
font = new Font(display,"Helvetica",22,SWT.ITALIC); | |
e.gc.setFont(font); | |
e.gc.drawText("Shoes!",30,60, SWT.DRAW_TRANSPARENT); | |
font.dispose(); | |
} | |
}); | |
shell.setSize(165, 185); | |
shell.open(); | |
while (!shell.isDisposed()) { | |
if (!display.readAndDispatch()) { | |
display.sleep(); | |
} | |
} | |
} | |
public static void main(String[] args) { | |
Display display = new Display(); | |
new SwtApp(display); | |
display.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment