开发者

SWT Text widget does not show up

开发者 https://www.devze.com 2023-03-21 04:01 出处:网络
I\'m trying to have "Hello SWT" show up in the center of a window in SWT, but nothing is showing.

I'm trying to have "Hello SWT" show up in the center of a window in SWT, but nothing is showing.

SWT Text widget does not show up

Here is my simple code (scala.version=2.9.0-1, swt:3.7.0-win32):

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("He开发者_开发知识库llo SWT")
    shell.pack()
    shell.open()
    while (!shell.isDisposed) {
      if (!display.readAndDispatch) {
        display.sleep()
      }
    }
    display.dispose()
  }
}


Add this line after creating your shell:

shell.setLayout(new FillLayout)
0

精彩评论

暂无评论...
验证码 换一张
取 消