Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx 向导窗格:禁用';以前的';屏幕上的按钮_Javafx_Wizard_Controlsfx - Fatal编程技术网

Javafx 向导窗格:禁用';以前的';屏幕上的按钮

Javafx 向导窗格:禁用';以前的';屏幕上的按钮,javafx,wizard,controlsfx,Javafx,Wizard,Controlsfx,如何禁用ControlsFX向导窗格屏幕上的“上一步”按钮?我正在用这个方法prev.setDisable(true)尝试它,但我得到的是NullPointerException public class MainApp extends Application { Wizard wizard = new Wizard(); WizardPane1 page1 = new WizardPane1(); WizardPane page2 = new WizardPane(

如何禁用ControlsFX
向导窗格
屏幕上的“上一步”按钮?我正在用这个方法
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() {}
}

我没有尝试过,但根据
向导的源代码,它添加了自己的“Previous”按钮,要查找它,您可能需要先使用
按钮数据来查找,以获得对相同
按钮类型的引用:

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

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

@覆盖
公用void onEnteringPage(向导){
ObservableList=getButtonTypes();
用于(按钮类型:列表){
if(type.getButtonData().equals(ButtonBar.ButtonData.BACK\u PREVIOUS)){
节点prev=查找按钮(类型);
prev.visibleProperty().setValue(Boolean.FALSE);
}
}
} 

这将禁用该按钮

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

什么是向导类?您好,您可以从本页查看s.o.println(getButtonTypes())的打印内容;在onEnteringPage()方法中?输出:[ButtonType[text=Vorheriger,buttonData=BACK\u PREVIOUS],ButtonType[text=Nächster,buttonData=NEXT\u FORWARD],ButtonType[text=Fertigstellen,buttonData=FINISH],ButtonType[text=Abbrechen,buttonData=CANCEL\u CLOSE]]我的文本是德语(text=…)我没有NullPointerException,但该按钮未被禁用。您正在隐藏该按钮,而不是按照问题中的要求禁用它。除此之外,它与另一个答案没有区别。你是对的。我有一个隐藏的解决方案,但不是禁用。是的,它是有效的。为了算法的清晰性,我更喜欢使用while而不是For with break。但这只是一个装饰性的细节。
@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); 
         }
    });       
}