|
JNIPort for Dolphin Smalltalk |
|
Back to Goodies |
Ghost-class ExamplesThis section is an example of using ghost classes to create and display a Swing window.
JNIPort should be configured to use ghost classes and support callbacks.
To configure ghost classes, ensure that the list of 'watcherClasses' under
'jniPortSettings' includes Since AWT/Swing uses Java threads, you should make sure that the JNI Helper is installed, or that you are not hooking the Java runtime's debugging output. If you followed the instructions in the installation walkthrough then JNI Helper will be configured. Ensure that a properly configured JMV is running, and open a new workspace. We start, as always, by getting a reference to the JVM object:
First we make an instance of
Now, we make sure that the frame won't call
Now we ask the frame to display itself (calling
We can hide the frame:
And show it again:
Now we'll create a scrollable panel that will display a picture (chose some handy
JPEG file). Notice how the delay is much shorter this time; much of Swing was
already loaded as a result of finding
Add the new pane to the frame and ask the frame to lay itself out again, which should display the picture:
And remove the pane:
Close the frame:
|
Copyright © Chris Uppal, 2003-2005
Java, JNI (probably), JVM (possibly), and God knows what else, are trademarks of Sun Microsystems, Inc.