+1 to @AndrewThompsons comment.
The only other problem I can see is you dont honor the paint chain.
Also always remember to honor the paint chain by calling super.XXX
implementation of overriden paint methods (and for that matter any overriden method), unless you know what you are doing and are purposely not calling their super
s implementation, or else visual artifacts like the ones you describe could/will happen.
To do this you would call super.paintComponent(Graphics g)
as the first method in overridden paintComponent
like so:
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
//do other drawings here
}
Also note how I use @Override
annotation so that I am sure I am overriding the correct method.