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

2017/4/23

No suitable constructor found for GreenfootImage

Raavi Raavi

2017/4/23

#
Hi, I've been looking to create a simple quiz game, but every time I input a color, it gives an error warning "No suitable constructor found for GreenfootImage(java.lang.String, int, greenfoot.Color) Here is my class for the Question subclass in Actor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 
 
public class Questions extends Actor
{
    private boolean Continue = true;
    private String text;
    public void act()
    {
         question1();
          
    }   
 
    public void question1() {
        java.awt.Color co = new java.awt.Color(255, 255, 255);
        Color col = new Color(255, 255, 255);
        GreenfootImage textImage = new GreenfootImage("Bahasa Pemrograman Java merupakan turunan dari bahasa pemrograman: ", 4, col);
        GreenfootImage image = new GreenfootImage(textImage.getWidth()+12, 36);
        image.setColor(new Color(255, 255, 255));
        image.fill();
        image.setColor(new Color(0, 0, 196));
        image.fillRect(3, 3, image.getWidth()-6, 30);
        image.drawImage(textImage, 6, 6);
         
         
    }
}
Can you help explain in which part I am wrong?
Super_Hippo Super_Hippo

2017/4/23

#
The constructor you are searching for needs another argument, the background color.
You need to login to post a reply.