Forums Register Login

How to deal with the GraphicsEnvironment abstract class ?

+Pie Number of slices to send: Send
I tried the following code and get the error message shown in the comment.
I do not understand what the following explanation/hint means :
"Instances must be obtained from a suitable factory or query method."
What is a factory or query method ?



+Pie Number of slices to send: Send
It might be best to focus on the missing method first: it's a static method of GraphicsEnvironment--you can't just call it without a class reference.

The error message means exactly what it says, though--you can't instantiate a GraphicsEnvironment, you must call a factory method (a method that creates a GraphicsEnvironment) or query method (not sure, but a method that returns a GraphicsEnvironment).
+Pie Number of slices to send: Send
Thanks for your answer.

That's my problem : I do not find such a factory/query method in the API documentation.

Do you have an example that I get an idea where I have to look for such methods ?
+Pie Number of slices to send: Send
Yes, in the API documentation.
+Pie Number of slices to send: Send
I just found an example in the API :

GraphicsEnvironment gr = GraphicsEnvironment.getLocalGraphicsEnvironment();

Then the program works.
+Pie Number of slices to send: Send
 

Wolfgang Tintemann wrote:


Side note: that first line is useless. After the first line you overwrite the value of fontnames before using its previous contents. Even worse, it has in fact a negative impact. You create a String array with 10,000 elements. Although the elements are all null, there still is space for 10,000 elements.
+Pie Number of slices to send: Send
Moving to our GUIs forum, where we usually discuss such questions.
Dinner will be steamed monkey heads with a side of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1365 times.
Similar Threads
Applet argument?
Help Setting Font Face dynamically
Why does Font.getFont return null when looking for system font?
getFontList()
how to copy return list
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:29:33.