Screencast: Developing Swing with JavaRebel
June 12th, 2008 by Jevgeni KabanovWe start by launching the application with “-noverify -javaagent:javarebel.jar” added to the VM params in the Eclipse launch profile. We first add new field “BCC”, which immediately appears in a new window. We then also add a Send button, which first does nothing. We then proceed to add a listener that points to the new send() method. After we make the body of the method to show a message box it is visible in both new and old windows that had a listener added. Finally we refactor the class adding a field and showing its value in the message box. Note that old instances have the field, but it’s initialized to null, while the new instance works properly.
Since most of the Swing initialization will happen only once, a nice trick we found for making a component reinit itself is using the JavaRebel SDK as follows:
-
ReloaderFactory.getInstance().addClassReloadListener(
-
new ClassEventListener() {
-
public void onClassEvent(int eventType, Class klass) {
-
if (MyClass.class == klass) {
-
public void run() {
-
reinit();
-
}
-
});
-
}
-
}
-
});
1 Comment »
RSS feed for comments on this post. TrackBack URL
Leave a comment
Additional comments powered by BackType


[...] Kabanov has a screencast on changing the source code of a running Swing application with JavaRebel. Looking at the [...]
Pingback by Swing links of the week: June 15, 2008 : Pushing Pixels — June 16, 2008 @ 10:31 am