I have tried 2 variations of this code:
to try to create a GreenfootImage object with a font inside it that has a Courier New font.
I have also tried this just to utilize the drawString() method:
Neither creates a text object. It's just a green foot. But the code compiles. :/ What am I doing wrong?
EDIT: OH! Also, if I add another parameter to the setFont:
It no longer compiles...?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Label extends Actor { String text = "blah, blah" ; public void Label(String text) { // GreenfootImage image = new GreenfootImage(200, 200); //image.drawString(text, 10, 16); GreenfootImage image = new GreenfootImage(text, 14 , Color.BLACK, Color.WHITE, Color.RED); image.setFont( new Font( "Courier New" , 20 )); setImage(image); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Label extends Actor { String text = "blah, blah" ; public void Label(String text) { GreenfootImage image = new GreenfootImage( 200 , 200 ); image.drawString(text, 10 , 16 ); // GreenfootImage image = new GreenfootImage(text, 14, Color.BLACK, Color.WHITE, Color.RED); image.setFont( new Font( "Courier New" , 20 )); setImage(image); } } |
1 | image.setFont( new Font( "Courier New" , Font.BOLD, 20 )); |