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/Snippet4.rb
< JRuby | SWTSnippets
################################################################################ # 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' # # Shell example snippet: prevent escape from closing a dialog # # For a list of SWT example snippets ported to JRuby, see # http://wiki.eclipse.org/JRuby/SWTSnippets # class Snippet4 include_package 'org.eclipse.swt' include_package 'org.eclipse.swt.widgets' def self.main display = Display.new shell = Shell.new(display) b = Button.new(shell, SWT::PUSH) b.setText("Open Dialog ...") b.pack b.setLocation(10, 10) b.addListener(SWT::Selection) do dialog = Shell.new(shell, SWT::DIALOG_TRIM) dialog.addListener(SWT::Traverse) do |e| e.doit = false if e.detail == SWT::TRAVERSE_ESCAPE end dialog.open end shell.open display.sleep unless display.readAndDispatch until shell.disposed display.dispose end end Snippet4.main
Compare with the Java version.