本文整理汇总了Java中java.awt.GraphicsEnvironment.getAllFonts方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsEnvironment.getAllFonts方法的具体用法?Java GraphicsEnvironment.getAllFonts怎么用?Java GraphicsEnvironment.getAllFonts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.GraphicsEnvironment
的用法示例。
在下文中一共展示了GraphicsEnvironment.getAllFonts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String os = System.getProperty("os.name");
if (!os.startsWith("Mac")) {
return;
}
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
for (int i=0; i<fonts.length; i++) {
if (fonts[i].getPSName().equals("Helvetica-LightOblique")) {
helvFont = fonts[i];
break;
}
}
if (helvFont == null) {
return;
}
final HelvLtOblTest test = new HelvLtOblTest();
SwingUtilities.invokeLater(() -> {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add("Center", test);
f.pack();
f.setVisible(true);
});
test.compareImages();
}
示例2: main
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String[] instructions =
{
"You must have a printer available to perform this test and should use Win 98.",
"This bug is system dependent and is not always reproducible.",
" ",
"A passing test will have all text printed with correct font style.",
};
Sysout.createDialog( );
Sysout.printInstructions( instructions );
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
allFonts = ge.getAllFonts();
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PrintAllFonts());
if (pj.printDialog()) {
pj.print();
}
}
示例3: getAvailableFontNames
import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
private ObservableList<String> getAvailableFontNames()
{
ObservableList<String> fontNames = FXCollections.observableArrayList();
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment
.getLocalGraphicsEnvironment();
java.awt.Font[] fonts = graphicsEnvironment.getAllFonts();
for (java.awt.Font font : fonts)
{
String fontName = font.getFontName();
fontNames.add(fontName);
}
return fontNames;
}