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

2017/3/23

BOLD

adlafforest adlafforest

2017/3/23

#
Today, I opened my Greenfoot project, and all of a sudden, all of my font settings were wrong. super(600, 400, 1); getBackground().setColor(Color.GRAY); getBackground().fill(); getBackground().setColor(Color.BLUE); getBackground().setFont(new Font("", Font.BOLD, 50)); getBackground().drawString("What country is this?", 30, 70); For instance, here, the BOLD is underlined in red. Does anyone know how to fix this problem?
danpost danpost

2017/3/23

#
adlafforest wrote...
Today, I opened my Greenfoot project, and all of a sudden, all of my font settings were wrong.
Did you recently install a newer version of greenfoot? The newer version has a major change in color and font usage.
adlafforest adlafforest

2017/3/23

#
I did not download anything, but when I opened my program it indicated that it had 'updated?' to the newer version of greenfoot. Is there any easy fix for my font problem?
danpost danpost

2017/3/23

#
Try this for setting the font:
1
getBackground().setFont(new Font("", true, false, 50));
(refer to the greenfoot.Font class documentation).
adlafforest adlafforest

2017/3/23

#
It says: cannot find symbol - method getBackground()
danpost danpost

2017/3/23

#
adlafforest wrote...
It says: cannot find symbol - method getBackground()
You gave this code above:
1
2
3
4
5
6
7
super(600, 400, 1);
 
getBackground().setColor(Color.GRAY);
getBackground().fill();
getBackground().setColor(Color.BLUE);
getBackground().setFont(new Font("", Font.BOLD, 50));
getBackground().drawString("What country is this?", 30, 70);
If it originally worked, then there should be no issues (as far as 'getBackground' is concerned) with replacing line 6 with the line I gave above. You would be getting errors on all the lines (lines 3 through 7) if that were the case.
adlafforest adlafforest

2017/3/23

#
It worked. Thank you so much. GreenfootImage image = new GreenfootImage(500, 35); image.setColor(colour); image.setFont(new Font("SansSerif", Font.BOLD, 14)); image.drawString(text, 70, 30); setImage(image); This is the second place where the BOLD is wrong. What could I do to fix this problem?
danpost danpost

2017/3/23

#
adlafforest wrote...
< Code Omitted > This is the second place where the BOLD is wrong. What could I do to fix this problem?
Same thing -- replace 'Font.BOLD' with 'true, false'.
You need to login to post a reply.