Who is calling paintComponent?

For some reason, my paintComponent (Graphics g) method is called endlessly. It seems I can’t say who is calling it, even if I give StackTrace in a call (this is an event that was sent and processed).

Are there any simple ways to find out who triggers the event?

Update: I found the reason, and now I understand the reason. Anyone who answers correctly will receive an answer to the question.

Here is the code causing the problem:

@Override
public void paintComponent(Graphics g)
{
    myJButton.setIcon(ResourceLoader.getImageIconWithLocale(MY_BUTTON_IMAGE));
    super.paintComponent(g);
}

FYI: This is really hard! This is not obvious when you look at the code. I made the assumption that it was wrong.

+3
source share
4 answers

SetIcon (ImageIcon) , ImageIcon .

ResourceBundle, , , , . .

ResourceLoader ( ) ImageIcon. , , . , , setIcon ( , JButtons), , newIcon!= OldIcon.

HashMap ResourceLoader, , (, , ). , .

+1

, , - . , , . , , .

- , , /.

+2

repaint() ? , ( ) , "" paintComponent() , .

0

, paintComponent(). .

Swing , . , Icon , , , .

0

Source: https://habr.com/ru/post/1760791/


All Articles