Elliotte Harold wrote:
>This hack works but it allows multiple instances of the special characters
>palette to run simultaneously. How do we find out if this process is
>already running, so we only launch it if it isn't already running?
The exec() of "/System/.../CharPaletteServer" returns a Process, which one
can hold onto. There isn't a Process.isAlive() method, but you can call
Process.exitValue() in a try/catch block to determine the Process's state.
Basically, if it returns a value, the Process has terminated, but if it
throws IllegalThreadStateException the Process is not terminated.
Or you can spawn a daemon-Thread that just does Process.waitFor(), and then
have it manage a directly represented state value.
Anyway, it'd be pretty easy to improve the original CharacterPalette class
so it encapsulated all this Process control, and also gave a
setVisible(boolean) method to further control palette visibility.
Process.destroy() should cause the palette to disappear, because it's just
a process.
I'd probably make CharacterPalette a singleton, to further encapsulate the
control to a singleton instance, but it's not necessary in order to get the
basic encapsulation.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden