Java code:
import javax.swing.Timer;
class Main {
public static void main(String args[]) {
MyListener myListener = new MyListener();
Timer timer = new Timer(1000, myListener);
timer.start();
while(timer.isRunning()) {
System.out.print(".");
}
}
}
Scala code:
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class MyListener extends ActionListener {
override def actionPerformed(arg0: ActionEvent) {
println("Do something");
}
}
Command line:
scalac MyListener.scala
javac Main.java
java -cp /usr/share/java/scala-library.jar:. Main