WizardPane : Disable 'Previous' button on a screen

▼魔方 西西 提交于 2019-12-06 11:44:25

This will disable the button.

@Override 
public void onEnteringPage( Wizard wizard ) { 
     for ( ButtonType type : getButtonTypes() ) {
         if ( type.getButtonData().equals(ButtonBar.ButtonData.BACK_PREVIOUS) ){
             System.out.println("Found Back button");
             previous_button = (Button) lookupButton( type );
             break;
         }
     }

     Platform.runLater(new Runnable() {
         @Override 
         public void run() {        
          previous_button.setDisable(true); 
         }
    });       
}

I didn't try but according to source code of Wizard, it adds its own "Previous" button, and to lookup it you may need to get the reference exactly to the same ButtonType by first looking it up using the ButtonData:

WizardPane page3 = new WizardPane()
{
    @Override
    public void onEnteringPage( Wizard wizard )
    {
        for ( ButtonType type : getButtonTypes() )
        {
            if ( type.getButtonData().equals(ButtonBar.ButtonData.BACK_PREVIOUS) )
            {
                Node prev = lookupButton( type );
                prev.setDisable( true );
                break;
            }
        }
    }
};

This is the solution and it works :))

@Override
public void onEnteringPage(Wizard wizard) {

    ObservableList<ButtonType> list = getButtonTypes();

    for (ButtonType type : list) {
        if (type.getButtonData().equals(ButtonBar.ButtonData.BACK_PREVIOUS)) {
            Node prev = lookupButton(type);
            prev.visibleProperty().setValue(Boolean.FALSE);

        }
    }
} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!