aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to deal with the GraphicsEnvironment abstract class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to deal with the GraphicsEnvironment abstract class ?" Watch "How to deal with the GraphicsEnvironment abstract class ?" New topic
Author

How to deal with the GraphicsEnvironment abstract class ?

Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

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 ?




Time isn't Money, Money is Time.
The man who works looses his time ( spanish proverb )
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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).
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

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 ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yes, in the API documentation.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

I just found an example in the API :

GraphicsEnvironment gr = GraphicsEnvironment.getLocalGraphicsEnvironment();

Then the program works.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
Moving to our GUIs forum, where we usually discuss such questions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to deal with the GraphicsEnvironment abstract class ?