// SWTApplication.scala // // Usage: // object HelloWorld extends SWTApplication // def createContents(parent: Shell) { // val layout = new FillLayout(SWT.VERTICAL) // parent.setLayout(layout) // // val fileLabel = new Label(parent, SWT.CENTER) // fileLabel.setText("hello world") // } // } // // Based on code from Bruce Eckel's _Thinking in Java_. import org.eclipse.swt._ import org.eclipse.swt.widgets._ import org.eclipse.swt.layout._ trait SWTApplication { var width: Int = 300 var height: Int = 300 var name: String = "Default Application Name" def createContents(parent: Shell): Unit def main(args: Array[String]) { val display = new Display() val shell = new Shell(display) shell.setText(name) createContents(shell) shell.setSize(width, height) shell.open() while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep() } display.dispose() } }