Mercurial > hg > jslab
diff examples/util/FontInfo.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/util/FontInfo.java Tue Jan 17 17:50:20 2012 +0000 @@ -0,0 +1,34 @@ +package eg.util; +import samer.core.*; +import java.awt.*; + +public class FontInfo implements Agent +{ + public FontInfo() + { + Shell.registerAgent(this); + Shell.exposeCommands(this); + } + + public void getCommands(Registry r) { + r.add("list1").add("list2").add("setfont"); + } + + public void execute(String cmd, Environment env) throws Exception + { + if (cmd.equals("list1")) { + String [] fonts=Toolkit.getDefaultToolkit().getFontList(); + Shell.print("fonts via Toolkit"); + for (int i=0; i<fonts.length; i++) { + Shell.print(" "+fonts[i]); + } + } else if (cmd.equals("list2")) { + String [] fonts=GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); + Shell.print("fonts via GraphicsEnvironment"); + for (int i=0; i<fonts.length; i++) { + Shell.print(" "+fonts[i]); + } + } + } +} +