开发者

swing: best way to make components enabled/disabled depending on the state of a model

I have a data model model which has a boolean flag connected, and I have a view with several components that I want to enable if model.isConnected() is true and disable if it is not开发者_开发百科. What is the best way to implement this?


Have your model accept PropertyChangeListeners (perhaps by delegating to a PropertyChangeSupport). Fire a PropertyChangeEvent whenever the connected state changes. Have the components listen to that property change, and change their visual state as appropriate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜