SWT文本小部件未显示

jil*_*len 2 java eclipse layout swt scala

package org.jilen.editor
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Shell
import org.eclipse.swt.widgets.Text
import org.eclipse.swt.SWT

object EditorApp {
  def main(args: Array[String]) {
    val display = new Display()
    val shell = new Shell(display)
    val text = new Text(shell, SWT.CENTER)
    text.setText("Hello SWT")
    shell.pack()
    shell.open()
    while (!shell.isDisposed) {
      if (!display.readAndDispatch) {
        display.sleep()
      }
    }
    display.dispose()
  }
}
Run Code Online (Sandbox Code Playgroud)

非常简单的代码,但没有显示文本.
窗口中间应该有"hello swt".
scala.version = 2.9.0-1,swt:3.7.0-win32
空窗口

Jea*_*let 5

创建shell后添加以下行:

shell.setLayout(new FillLayout)
Run Code Online (Sandbox Code Playgroud)