Set Background Color

In VASL, maps are surrounded by a white area, used for off-board counters and informational counters. The color of the background is set in but can be changed by changing its value in the VASL buildFile.

I would like to find an easier way to change the background, either via a preference or accessing the bgColor property in

VASL has a class ASLMap which extends ASLMap’s constructor calls super(); as its first action. I tried the following after that call, but it did not work:

super.bgColor = Color.cyan;

I have tried to access other methods from with an equal lack of success.

Any thoughts would be greatly appreciated.

Make it:

super.bgColor = Color.cyan;

And I think that should do it.



Thanks Brian

clearMapBorder() wants a Graphics parameter which I have not been able to provide.

Normally, it would be something like
Graphics g = XXX.creategraphics();

But I don’t know what the XXX should be. Should it be the viewport? In some examples I found it was a BufferedImage.

Appreciate the help.


Oh right! If you’re already subclassing Map then I think you can just do


Or more formally…


super.bgColor = Color.cyan;

I’m not certain you need as many explicit “super”'s there as I have put. Many/most/all can probably be omitted.

Like this might work–
bgColor = Color.cyan;


That will not work.

Map.clearMapBorder() is supposed to be called only when the Map component is being painted. It should not be called from anywhere else.

If you want to change the background color, you can do that by setting the BACKGROUND_COLOR property that Map has. Alternatively, bgColor is a protected member of Map and since ASLMap is a subclass, this means you have access to it and can set it directly: bgColor = Color.cyan;

That’s what he was trying in his first message to the thread and it wasn’t working.

Maybe instead of directly calling clearMapBorder, the right thing to do is a full paint() of “the whole map”?

bgColor = Color.cyan;

So maybe that?

Of course then I don’t understand why “repaint()” doesn’t do it, but then again I’m on record as never understanding the difference between paint()/repaint()/update() in swing.

When you tried assigning to bgColor in the ASLMap ctor, did you check in a debugger where it’s being reset after that?

that did it. I was resetting the color too soon - in the ASLMap constuctor and it was getting overwritten when the Map class was being built. I moved it else where in ASLMap class and it worked perfectly: set the new color, call repaint().

Thanks for all the help from you both.