Oliver@oliver-desktop:~/JavaProjects$ java SaveImage
Font defined: java.awt.Font[family=Serif,name=Serif,style=bold,size=40]
Font used: java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12]
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Oliver Stuttgart wrote:
I however wonder, if my solution is good style, as the thing with 'Graphics g = image.createGraphics();' looks somewhat strange to me!?
I thought that I could replace 'image' with 'g' in line 17, however this did not work. When I left it at 'image'", everything was OK, even the created PNG file.
This is the code:...
"If the facts don't fit the theory, get new facts" --Albert Einstein
Paul Clapham wrote:Sorry, I'm lost. Originally you had a problem but then it was solved, wasn't it? So do you still have a problem? And what is it?
"If the facts don't fit the theory, get new facts" --Albert Einstein
Oliver Stuttgart wrote:I am now quite confused if my code is generally OK or not and how I could improve it.
Hunter McMillen wrote:I think you should re explain what you are having trouble with in a more organized manner. [...]
"If the facts don't fit the theory, get new facts" --Albert Einstein
Oliver Stuttgart wrote:
I am especially wondering about what happens in line 9 and if it is OK what I am doing in 11 and 12. In 9 I say, that g shall be a Graphics objects, in 11 I set the font, in 12 I write a string on it. So far so good.
Somehow these modifications stay connected with the image object. This pretty much confuses me. I would have expected, that g is now the object which I will have to put into ImageIO.write, what however doesn't work.
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|