Menu

Programatically Disable/Enable Button

2016-09-02
2016-09-06
  • Peter Katzmann

    Peter Katzmann - 2016-09-02

    High,
    im currently in transition from messagebox 2.x to 3.x and now i hit a big obstacle.
    The 2x release provided the possibility to access a button object so it was possible to enable or disable the button programatically.
    Is there any way to do this also in the 3.x release ?

    peter

     

    Last edit: Peter Katzmann 2016-09-02
  • Dieter Steinwedel

    Hi Peter,

    yes. You have two methods "withButton()". One of them has a paramter with a Button. You simply create your own Button instance and added as parameter to the method. Another way is to get the window from the message with getWindow() and iterate throw the child components. But that is not so comfortable.

    BTW, I'm interested in the use-case: Why do you need to disable a button? Is the state statically or does the button state change during a messagebox is displayed? Maybe a feature missing.

     
  • Peter Katzmann

    Peter Katzmann - 2016-09-05

    The Button State is changing due to some validation restrictions of some input fields.
    Like you have an Dialog to fill Input data a and the save button is disabled till you have filled all necessary fields.
    This is quite better then to let the user push the save and then complain about missing data....

     
  • Peter Katzmann

    Peter Katzmann - 2016-09-05

    I looked for the withButton method and it is a possible work around but imho it would be better to provide something to retrieve a button object like it was possible in the 2.x series.

     
  • Dieter Steinwedel

    Ok, I understand your use case. I have identified 2 new enhancements:
    1. You can change via ButtonOption the button state to disabled.
    2. Lookup method like 'Button getButtonBy(ButtonType buttonType)'.

     
  • Dieter Steinwedel

    FYI, I have released a new version.

     
  • Peter Katzmann

    Peter Katzmann - 2016-09-06

    Yeah,
    i saw it and will try it out immediately.

    Thanks

    peter

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.