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.
JRuby/SWTSnippets/Snippet1.rb
################################################################################ # Copyright (c) 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ################################################################################ require 'java' # # example snippet: Hello World # # For a list of SWT example snippets ported to JRuby, see # http://wiki.eclipse.org/JRuby/SWTSnippets # 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 line above spins the event loop; it's the short form of: # while !shell.isDisposed # if !display.readAndDispatch # display.sleep # end # end display.dispose end end Snippet1.main
Compare with the Java version.