Created
March 10, 2012 05:55
-
-
Save ashbb/2010465 to your computer and use it in GitHub Desktop.
Why doesn't a red rectangle appear within Thread block?
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
| require 'java' | |
| require 'swt' | |
| module Swt | |
| include_package 'org.eclipse.swt' | |
| include_package 'org.eclipse.swt.widgets' | |
| include_package 'org.eclipse.swt.graphics' | |
| end | |
| class Object | |
| include Swt | |
| end | |
| display = Swt::Display.new | |
| shell = Swt::Shell.new display | |
| shell.setSize 300+16, 300+38 | |
| cs = Swt::Composite.new shell, Swt::SWT::NONE | |
| cs.setSize 300, 300 | |
| shell.open | |
| #Thread.new do | |
| gc = Swt::GC.new cs | |
| gc.setBackground Swt::Color.new(display, 255, 0, 0) | |
| gc.fillRectangle 100, 100, 100, 100 | |
| #end | |
| while !shell.isDisposed do | |
| display.sleep unless display.readAndDispatch | |
| end | |
| display.dispose |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above snippet works. A red rectangle appears on a window. But after deleting number sign
#s, I mean usingThread, nothing appear. Why?