Swing - Changing the content of a panel using UpdateUI

后端 未结 2 601
没有蜡笔的小新
没有蜡笔的小新 2020-12-21 21:07

I am going through a legacy application which is using Swing and i am struggling to figure out how the screens are changing when a user clicks a button. One of the reasons i

相关标签:
2条回答
  • 2020-12-21 21:40

    This is not an appropriate use of updateUI(), which "Resets the UI property to a value from the current look and feel." As the example itself may be unreliable, consider studying another. GoogleOlympiad, for example, sets a label's icon using a (cached) image.

    ImageIcon image = getImage(index);
    imageLabel.setIcon(image);
    


    (source: drjohnbmatthews at sites.google.com)

    0 讨论(0)
  • 2020-12-21 21:52

    As per comments by ziggy (glad it helped)

    Have a look at the PropertyChangeListeners that appear to be added in the code. In particular the propertyChange(PropertyChangeEvent e) method is where the code which changes the content will be present.

    +1 to trashgod nice example/advice as always

    0 讨论(0)
提交回复
热议问题