WizardPane:禁用'上一页'屏幕上的按钮

时间:2015-08-26 07:59:52

标签: javafx wizard controlsfx

如何禁用'上一页' ControlsFX WizardPane屏幕上的按钮?我正在尝试使用此方法prev.setDisable(true),但我所拥有的是NullPointerException

public class MainApp extends Application {
    Wizard wizard = new Wizard();

    WizardPane1 page1 = new WizardPane1();

    WizardPane page2 = new WizardPane();

    WizardPane page3 = new WizardPane() {
        @Override
        public void onEnteringPage(Wizard wizard) {
            Node prev = lookupButton(ButtonType.PREVIOUS);
            prev.setDisable(true);
        }
    };

    page1.setContent(page1.getInit());

    wizard.setFlow(new LinearFlow(page1, page2, page3));
    wizard.showAndWait();

}

public class WizardPane1 extends WizardPane {
      public void initWizard() {}
}

2 个答案:

答案 0 :(得分:0)

这将禁用该按钮。

@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); 
         }
    });       
}

答案 1 :(得分:-1)

这是解决方案,它有效:))

#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>