834477 wrote:This is the normal way of doing it, but you have some strange code there like 'g.create();' g is passed in by the sytem as a reference to your graphic context--don't mess with it, other than using it as a reference to your graphic context. If you need it cleared do a "this.super();" call at the beginning of your paint component.
I have a custom component "+DrawingBoard+" who is a JScrollPane. This "+DrawingBaord+" contains an inner subclass of JDesktopPane who override the paintComponent(Graphics) method to paint another custom component named "+Sheet+" :
The "+Sheet+" also override paint(Graphics) to draw a grid and then call the paint(Graphics) method all custom "+Shape+"s.This is not just a no no, but HELL NO! if you are going to overide something in your graphics for SWING, then you do paintComponent. I recomend that you do back into the SWING tutorial and study it more completely before rewriting this app.