This site requires JavaScript, please enable it in your browser!
Greenfoot back
Nosson1459
Nosson1459 wrote ...

2017/2/1

Font

Nosson1459 Nosson1459

2017/2/1

#
How do you use setFont(java.awt.Font f) (from Greenfoot)?
Super_Hippo Super_Hippo

2017/2/1

#
Usually like this: - get the current font from the image - call the deriveFont method on it and apply a new style and/or a new size - set the font to the image again For example (copied from my Bomberman game where I changed the size of the Text):
1
2
3
4
5
GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT);
Font font = image.getFont();
font = font.deriveFont(FONT_SIZE);
image.setFont(font);
image.setColor(new Color(red,green,blue) );
Nosson1459 Nosson1459

2017/2/2

#
Can you show me where in "The Java™ Tutorials" or in the Java API this is (font.deriveFont()), so I can understand it better and use it the way I might want to (I don't have anything specific I want to do, I'm just wondering)?
Super_Hippo Super_Hippo

2017/2/2

#
Nosson1459 Nosson1459

2017/2/3

#
Thanks.
Nosson1459 Nosson1459

2017/2/3

#
I just noticed this new Greenfoot Version: 3.1.0 which has Color and Font in it with this method but I didn't download it (at the time) and I still wanted to see the Java one.
Super_Hippo Super_Hippo

2017/2/3

#
Oh, that's great. I didn't see the new version yet.
You need to login to post a reply.