In java.awt
package, we have the Font
class. I want to see a list of all available fonts I have.
According to the documentation, this is possible through the GraphicsEnvironment#getAllFonts()
method, but it is an abstract class. Why would I have to extend it, if it's supposed to tell me what fonts I have? The documentation for GraphicsEnvironment
has no non-abstract subclasses, so I am confused on how I can view my options.
CodePudding user response:
To get a concrete instance of a GraphicsEnvironment
, call the static method GraphicsEnvironment.getLocalGraphicsEnvironment()
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Examples of use can be seen in answers to: