Jeremy Watts wrote:
> is it possible in java graphics to draw 'over' an existing graphic as
> if it werent there? a background graphic in other words, similar to a
> background picture on the windows desktop.
>
> what i am after is a 'graph paper' type background effect with the
> rulings of the graph paper lines visible in the background, and then
> the ability to draw over that as if it were blank.
>
> how would you do this sort of thing in java? sorry if the question
> seems rudimentary but i am new to java graphics.
As is so often the case, there are several ways to do this. I don't know
which one would necessarily be the best one to use for your situation,
but I will list the ones that come to my mind:
1. If you're mostly doing Graphics.drawLine, etc., then you can start
the painting procedure by drawing the graph paper lines and then proceed
to draw the rest of the stuff on top of that.
2. If the graphics is complex with different components, then providing
a special container pane with the lines would be better. Be sure to
check that the child panes are transparent though.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


|