001package ca.bc.webarts.javaFX.wizard.survey; 002 003import javafx.beans.property.*; 004import javafx.beans.value.*; 005import javafx.application.Application; 006import javafx.scene.*; 007import javafx.stage.Stage; 008 009import java.util.Stack; 010 011import ca.bc.webarts.javaFX.wizard.Wizard; 012 013/** This class displays a survey using a wizard. */ 014public class Survey extends Application 015{ 016 public static void main(String[] args) throws Exception 017 { launch(args); } 018 019 @Override 020 public void start(Stage stage) throws Exception 021 { 022 // configure and display the scene and stage. 023 stage.setScene(new Scene(new SurveyWizard(stage), 400, 250)); 024 stage.show(); 025 } 026} 027 028/** This class shows a satisfaction survey. **/ 029class SurveyWizard extends Wizard 030{ 031 public static final SurveyData surveyData_ = SurveyData.instance; 032 Stage owner; 033 034 public SurveyWizard(Stage owner) 035 { 036 super(new ComplaintsPage(), 037 new MoreInformationPage(), 038 new ThanksPage()); 039 this.owner = owner; 040 } 041 042 public void finish() 043 { 044 System.out.println("Had complaint? " + surveyData_.hasComplaints.get()); 045 if (surveyData_.hasComplaints.get()) 046 { 047 System.out.println("Complaints: " + (surveyData_.complaints.get().isEmpty() ? "No Details" : "\n" + surveyData_.complaints.get())); 048 } 049 owner.close(); 050 } 051 052 public void cancel() 053 { 054 System.out.println("Cancelled"); 055 owner.close(); 056 } 057} 058 059/** Simple placeholder class for the customer entered survey response. */ 060class SurveyData 061{ 062 BooleanProperty hasComplaints = new SimpleBooleanProperty(); 063 StringProperty complaints = new SimpleStringProperty(); 064 static SurveyData instance = new SurveyData(); 065} 066