Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created July 2, 2009 17:28
Show Gist options
  • Save hakobe/139600 to your computer and use it in GitHub Desktop.
Save hakobe/139600 to your computer and use it in GitHub Desktop.
import org.eclipse.swt._
import org.eclipse.swt.layout._
import org.eclipse.swt.widgets._
import org.eclipse.swt.events._
object MySWT {
def main(args:Array[String]) = {
val display = new Display()
val shell = new Shell(display)
shell.setText("MySWT")
shell.setSize(200, 100)
shell.setLayout(new GridLayout());
val l1 = new Label(shell, SWT.PUSH);
l1.setText("Hello");
shell.open()
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep()
}
}
display.dispose()
}
}
SCALAC = 'scalac'
SCALA = 'scala'
JAVACMD = '/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java'
JAVA_OPTS = '-XstartOnFirstThread'
CLASSPATH = %w(
/Applications/eclipse/plugins/org.eclipse.swt.cocoa.macosx_3.5.0.v3550b.jar
)
PROJECT = 'MySWT'
SRCS = FileList['*.scala']
def opt_classpath
classpath = CLASSPATH
classpath.unshift('.')
"-classpath \"#{classpath.join(':')}\""
end
task :default => ['compile', 'run']
task 'compile' do
sh "#{SCALAC} #{opt_classpath} #{PROJECT}.scala"
end
task 'run' do
sh "env JAVACMD=#{JAVACMD} JAVA_OPTS=#{JAVA_OPTS} #{SCALA} #{opt_classpath} #{PROJECT}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment