Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Infinite repaint loop

843806Apr 23 2009 — edited Apr 24 2009
Hello 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 !
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2009
Added on Apr 23 2009
15 comments
624 views