How to disable UI control based on domain object's state?

Posted by Subb on Stack Overflow See other posts from Stack Overflow or by Subb
Published on 2009-08-16T15:39:17Z Indexed on 2010/05/11 17:04 UTC
Read the original article Hit count: 269

Filed under:
|
|

Here's my problem. I have a somewhat complex domain object, which, depending on its state, responds to certain actions. I think the state pattern is pretty much the solution for that. However, I need to display which actions are possible at any moment in the UI.

Ex: The domain object is an audio player. Some songs can't be skipped (like ads), so I need to disable the "next" and "previous" buttons in the GUI so the user have some kind of feedback of which action he can execute.

I've looked at Swing's Action class (note: this is not a Java project), but I think I would need to keep every Actions in my domain object class (audio player), so it can enable or disable them depending on its own state (thus, affecting the UI).

Is it the way to do it?

© Stack Overflow or respective owner

Related posts about design

Related posts about gui