Quantcast
Channel: alvinalexander.com - default
Viewing all articles
Browse latest Browse all 18

How to get the default system font in a Java/Swing application

$
0
0

I haven’t tested this with other Java components, but if you want/need to get the “system font”, this code gets the default system font from a JEditorPane component:

val outputArea = new JEditorPane
val fontFamily = outputArea.getFont.getFamily

That code is written in Scala, but as you can see, it converts easily to Java. On Mac OS X 10.10, fontFamily ends up being “Lucida Grande”.

read more


Viewing all articles
Browse latest Browse all 18

Trending Articles