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

2020/3/21

Error with import.java.awt.* and import.greenfoot.*

Zachary2304 Zachary2304

2020/3/21

#
I have made a code for my game at college and come home to sort my code out some more but getting errors on fonts and stuff how do i rectify this please
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.*; 
/**
 * Write a description of class InstructionWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class InstructionWorld extends World
{

    /**
     * Constructor for objects of class InstructionWorld.
     * 
     */
    public InstructionWorld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1);
        GreenfootImage gi= new GreenfootImage(600,400);
        gi.setColor (Color. GREEN);
        gi.fill();
        gi.setColor(Color.WHITE);
        gi.setFont(new Font("Times New Roman")); 
        gi.drawString("What would you like to do?",80,100);
        setBackground(gi);
        addObject(new ButtonPlay(), 300, 150);
        addObject(new ButtonQuit(), 300, 250);
        addObject(new ButtonInstructions(), 300, 350);
    }
}
danpost danpost

2020/3/22

#
You are probably using a newer version of greenfoot at home. Try commenting out line 2 and line 24. Next to line 24, add the following line:
gi.setFont(new Font("Times New Roman", 28));
You need to login to post a reply.