Ralf is a software engineer with a history as Eclipse committer and project lead.
In recent years, he devoted himself to JavaScript technologies and helped pulling off …
Often when I use SWT templates in a presentation, some people look amazed, so I thought it’s worth sharing. If you write SWT code and don’t know these templates yet, you may be wasting time typing the same code over and over again.
Whenever you write an SWT snippet, you start with a Display, a Shell, and the SWT mainloop. That’s this piece of code that you can never remember, something with readAndDispatch()
and display.sleep()
. But Eclipse can help you out. You only need to type main
and hit Ctrl+Space.
Select SWT mainloop (pro tip: you can use the ↓ key for that ;-)) and there you go:
Well, and if you want to create a push button next, there’s also a template for that:
You even get a selection listener for free, as you’re probably going to need it.
There are templates for most SWT widgets, for GridLayout and GridData, and also for running code in UI thread (try execute
). Of course, you can edit the templates to fit your needs (Preferences > Editor > Templates) and if you’re missing something, you can add your own templates.
Ralf is a software engineer with a history as Eclipse committer and project lead.
In recent years, he devoted himself to JavaScript technologies and helped pulling off …