How can I set the text color of my label class to be white? I already imported java.awt.Color package but I don't know how to use it very well.


1 2 3 4 5 6 | public Label(String text) { GreenfootImage img = new GreenfootImage ( 100 , 30 ); img.drawString(text , 2 , 20 ); setImage(img); } |
1 | img.setColor(Color.white); //Or whatever other color you want. |
1 2 3 4 5 6 7 8 9 10 | //Changing image when clicked if (Greenfoot.mouseClicked( this )) setImage(newImage); //Dragging (I know you'll want this one) if (Greenfoot.mouseDragged( this )) { MouseInfo mi = Greenfoot.getMouseInfo(); setLocation(mi.getX(), mi.getY()); } |