Mercurial > hg > jslab
comparison examples/util/FontInfo.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package eg.util; | |
2 import samer.core.*; | |
3 import java.awt.*; | |
4 | |
5 public class FontInfo implements Agent | |
6 { | |
7 public FontInfo() | |
8 { | |
9 Shell.registerAgent(this); | |
10 Shell.exposeCommands(this); | |
11 } | |
12 | |
13 public void getCommands(Registry r) { | |
14 r.add("list1").add("list2").add("setfont"); | |
15 } | |
16 | |
17 public void execute(String cmd, Environment env) throws Exception | |
18 { | |
19 if (cmd.equals("list1")) { | |
20 String [] fonts=Toolkit.getDefaultToolkit().getFontList(); | |
21 Shell.print("fonts via Toolkit"); | |
22 for (int i=0; i<fonts.length; i++) { | |
23 Shell.print(" "+fonts[i]); | |
24 } | |
25 } else if (cmd.equals("list2")) { | |
26 String [] fonts=GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); | |
27 Shell.print("fonts via GraphicsEnvironment"); | |
28 for (int i=0; i<fonts.length; i++) { | |
29 Shell.print(" "+fonts[i]); | |
30 } | |
31 } | |
32 } | |
33 } | |
34 |