Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JRuby/SWTSnippets/Snippet1.rb"

Line 12: Line 12:
 
         shell = Shell.new(display)
 
         shell = Shell.new(display)
 
         shell.open
 
         shell.open
         while !shell.isDisposed
+
 
            if !display.readAndDispatch
+
         display.sleep unless display.readAndDispatch until shell.isDisposed
                display.sleep
+
 
            end
+
# the above is the short form of:
        end  
+
#        while !shell.isDisposed
#      display.sleep unless display.readAndDispatch until shell.isDisposed
+
#            if !display.readAndDispatch
 +
#                display.sleep
 +
#            end
 +
#        end  
 +
 
 
         display.dispose
 
         display.dispose
 
     end
 
     end

Revision as of 01:40, 28 July 2009

require 'java'

# 
# example snippet: Hello World
#
class Snippet1
    include_package 'org.eclipse.swt.widgets'
    
    def Snippet1.main
        display = Display.new
        shell = Shell.new(display)
        shell.open

        display.sleep unless display.readAndDispatch until shell.isDisposed

# the above is the short form of:
#        while !shell.isDisposed
#            if !display.readAndDispatch
#                display.sleep
#            end
#        end 

        display.dispose
    end
end

Snippet1.main

Back to the top