Why are the slots in the connections passed as strings ?
Answer:
Ideally, the Java language would support getting a Method handle directly using syntax, and there are several suggestions in the Sun's Bugtracker / suggestion database for this. If this was present, we could eliminate the strings, but until such features exist in the language the String based approach is the best.
The listener approach taken by SWING is a subset of the Signals and Slots pattern implemented in Qt Jambi. If you feel that you have to use the listener approach taken by SWING then it is trivial to work around this though in your own code by making a type-safe approach on top of ours, e.g:
import com.trolltech.qt.*;
public abstract class SignalHandler1<T> {
public SignalHandler1(QSignalEmitter.Signal1<T> signal) {
signal.connect(this, "handle(Object)");
}
public abstract void handle(T arg);
}
The above approach is compile time checked, same as the pattern used by SWING.
However, we see that the listener pattern is not necessarily the most ideal as it results in a number of anonymous classes that are implemented inline, thus disrupting code readability. There is a JSR in the works that supports this and that takes the Qt Jambi approach with String based connections to modify properties.
On a side note... Qt has been using strings for signal / slot connections for over a decade and in practice this has proven to not be a major hurdle. The reason for this is that connections are typically made during the init phase of objects and therefore always checked and fixed at an early stage.