Infinite repaint loop
843806Apr 23 2009 — edited Apr 24 2009Hello again !
I have a JTextPane named "output", and a JLabel that contains an image named "squid".
the JLabel is located near the JTextPane and hiding a part of it.
I'm using a null layout and placing each object with setBounds().
When the JTextPane updates, the Image goes behind it.
To solve this problem I called "squid.repaint()" from the JTextPane's paint function to get the image in front of the JTextPane again.
for some reason, when I do that, the JTextPane's paint function is being called in an endless loop.
here's the code :
output=new JTextPane(){
{
setOpaque(false);
setEditable(false);
}
public void paintComponent(Graphics g){
squid.repaint();
Image icon=new ImageIcon("images/output.gif").getImage();
g.drawImage(icon, 0, outputPane.getVerticalScrollBar().getValue(), null);
super.paintComponent(g);
}
};
Thanks in advanced !