Enable/disable Next/Finish button in Wizard step


Within in a wizard step I am looking to disable the Next button on 'show/init' until manually enabled. The only way I can seem to make this work is by doing the below in getPreferredFocusedComponent(). The updateButtons() second param is canGoNext...

public JComponent getPreferredFocusedComponent() {
wizardContext.getWizard().updateButtons(false, false, false);
return super.getPreferredFocusedComponent();

The updateButtons() function doesn't seem to be effective in any other function (overridden or otherwise), not even _init() from the superclass(es).

There's no handle for the "next/finish" button either whereas there is one called getCancelButton(). I know the Next/Finish button is actually dual purpose.

What's the best way to achieve what I need? Or is that the wizard isn't meant to provide manual control over the buttons on purpose? From a user experience point of view, i'd rather not rely on validate() with a message each time there's an issue with fields. Better to have the next button enabled/disabled as a clear visual indicator.


Comment actions Permalink

Update - it could be because I am trying to update the state in the EDT. Using SwingUtilities.invokeLater() or ApplicationManager.getApplication().invokeLater() seems to help. 

Comment actions Permalink

Please try com.intellij.ide.util.projectWizard.WizardContext#requestWizardButtonsUpdate

Comment actions Permalink

Yann Cebron - I saw this method, but I don't see the benefit of notifying some (empty) registered listeners. What is it's intended use please?

I see an example of its use in AbtractWizard<T extends Step> for sure.

I have the outcome i need though, OTOH.


Please sign in to leave a comment.