Java Swing — Writing a Ui that will repaint itself based on changes to a custom data object

前端 未结 3 457
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 08:40

First things first -- I had posted a question earlier wherein i had asked for help as to why my code was not working and this question is acting upon the advice i got in tha

3条回答
  •  感动是毒
    2021-01-15 09:14

    Please verify that the PropertyChangeEvent does not fire. If it does fire, but the repaint does not happen, it might help to postpone the repaint a bit like this:

    //change this
    button.repaint();
    
    // to this
    SwingUtilties.invokeLater(new Runnable() { public void run() { button.repaint(); }});
    

    If the change event does not fire - disregard all after 'Please' ;)

提交回复
热议问题