Swing JPanel won't repaint

前端 未结 6 2136
傲寒
傲寒 2021-02-20 07:39

I have a simple object which extends JPanel, when the update() method is called on this object it it meant to add some labels to the panel and then rep

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-20 08:20

    Try calling revalidate(); repaint is not what you want.

    As per:

    API Docs

    Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

    revalidate() is basically a invalidate() followed by a validate().

    See this question.....

提交回复
热议问题