Amol Brid
Posts: 43
Nickname: amolbrid
Registered: Feb, 2004
|
|
Re: draw behind component.
|
Posted: Apr 7, 2005 11:10 AM
|
|
Hi,
If you are using Swings then you should override the paintComponent() method instead of paint() method for custom painting on the component.
You problem will be solved by overriding paintComponent() method of JPanel.
public void paintComponent(Graphics g) {
super.paintComponent(g); // don't forget to call this
g.drawLine (...);
g.fillPolygon (...);
}
While perfoming paint operation in swings the following methods get called in the given order: 1. paintComponent() - paints the component itself. 2. paintBorder() - draw the border of the component. 3. paintChildren() - asks the child controls to paint themselves.
These methods are called from the paint() method, therefore overriding of paint() method should be avoided.
Regards, Amol Brid.
|
|