Skip to content
Advertisement

Negative Number in fillRect()

I am using a negative number to have fillRect() go the opposite way. It works well on my computer, but my friends cannot see it working properly. What do I do?

page.fillRect (12, 12, -5, 10);

Advertisement

Answer

My guess is that you and your freind are using 2 different versions of Java. your supports fillrect with a negative value and your freind’s doesn’t. (or even sdk vs jre).

what that shows is that you should write this a different way to have your applet run on all versions.

why not simply move your x of -5 ?

if you want to do it in a more neat way

public void myfillRect(graphics page, int x, int y, int width, int height){
    if(width <0)
        x-=Math.abs(width);
    if(height <0)
        y-=Math.abs(height);

    page.rectfill(x,y,Math.abs(width), Math.abs(height));
} 
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement