very strange problem with paintComponent()functiom

Hi

i have strange error with panitComponant function in class extend JPanel ,when i create object from that class ans add it to certain frame it continously repeat excuting the paintComponent function in infinite loop until the following exception appears

fException in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

any solutions?

[379 byte] By [Elnegma] at [2007-10-3 12:01:12]
# 1
Dont call paintComponent(), call repaint().
CaptainMorgan08a at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...
# 2
i didn't call it Is it supposed tha when i create an object from that class this function excuted automatically when i include it in aframe?
Elnegma at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...
# 3
Show us your paintComponent method. If you have a setFont() or other certain methods inside your paintComponent, it will recurse forever.
.andisblue.a at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...
# 4

public void paintComponent(Graphics g)

{ super.paintComponent(g);

Graphics2D g2=(Graphics2D) g;

Line2D L;

float tempx,tempy,x,y;

g2.setColor(Color.BLACK);

g2.drawLine(0,260,580,260);

g2.drawLine(10,0,10,280);

x=(float)((QT.get(0).getX()*580)/MX);

y=(float)((QT.get(0).getY()*260)/MY);

g2.setColor(Color.BLACK);

for(int i=1;i<QT.size();i++)

{

tempx=(float)((QT.get(i).getX()*580)/MX);

tempy=(float)((QT.get(i).getY()*260)/MY);

L=new Line2D.Float(x,260-y,tempx,260-tempy);

g2.draw(L);

}

return;

}

This is the method>

Elnegma at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...
# 5
You should do all those calculations outside of your paintComponent() method.
CaptainMorgan08a at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...
# 6
> You should do all those calculations outside of your> paintComponent() method.i did that and the same result occured
Elnegma at 2007-7-15 14:37:48 > top of Java-index,Security,Cryptography...