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

2017/3/11

"java.awt.Color cannot be converted to greenfoot.color"

PenguinJ2 PenguinJ2

2017/3/11

#
Hi, I've been having some problems with my code and I'd really appreciate it if you could point out what is wrong.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import greenfoot.*;
import java.awt.Color;
 
public class HelpText extends Actor
{
    public void showText(String text)
    {
        setImage(new GreenfootImage(text, 28, java.awt.Color.BLACK, java.awt.Color.BLUE));
    }
     
    public void act()
    {
        showText("x");
    }   
}
The error is thrown at .BLACK , where it says "Incompatible types: java.awt.Color cannot be converted to greenfoot.color" Thanks in advance.
Super_Hippo Super_Hippo

2017/3/11

#
Remove line 2 and remove every 'java.awt.' in line 8. Greenfoot has its own Color class since version 3.1.0.
You need to login to post a reply.