Swing JPanel won't repaint

前端 未结 6 2260
傲寒
傲寒 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:14

    It turns out that the HoleCardsPanel wansn't adding to its parent frame properly, once that was fixed the adding of new JLabels works fine. I added call to the update() method to the event dispatch thread using SwingUtillities.invokeLater I additionaly had to call validate() from the uppermost component (in this case the JFrame)

提交回复
热议问题