Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Character Palette



Ian Cheyne wrote:

public class CharacterPalette {

public static void main(String[] args) {
try {
Runtime.getRuntime().exec("/System/Library/Components/CharacterPalette.component/Contents/SharedSupport/CharPaletteServer.app/Contents/MacOS/CharPaletteServer");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

As Bob barker used to say on truth or Consequences when someone actually answered the riddle, there's a second part o this question:


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? This one I figured out. You have to exec a "ps -awwx" (Yes, you have to use w twice.) and look for the command:

    public void actionPerformed(ActionEvent evt) {

try {
Process process = Runtime.getRuntime().exec("ps -awwx");
InputStream in = new BufferedInputStream(process.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String s = null;
while ((s = reader.readLine()) != null) {
if (s.indexOf(command) != -1) return;
}
Runtime.getRuntime().exec(command);
}
catch (Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}


    }

How skanky is that?

--
Elliotte Rusty Harold  email@hidden
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
_______________________________________________
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
References: 
 >Character Palette (From: Elliotte Harold <email@hidden>)
 >Re: Character Palette (From: Ian Cheyne <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.