@ Override public void initialize ( URL location , ResourceBundle resources ) { // Add an event handler to automatically close the stage in the event of // any exception encountered. addEventHandler ( WindowEvent . ANY , new EventHandler < WindowEvent > ( ) { @ Override public void handle ( WindowEvent window ) { Platform . runLater ( new Runnable ( ) { @ Override public void run ( ) { if ( isLoadingError ) { close ( ) ; } } } ) ; } } ) ; // Set default focus to the appropriate UI component Platform . runLater ( new Runnable ( ) { @ Override public void run ( ) { switch ( dialogType ) { case INFORMATION : okButton . requestFocus ( ) ; break ; case CONFIRMATION : yesButton . requestFocus ( ) ; break ; case CONFIRMATION_ALT1 : okButton . requestFocus ( ) ; break ; case CONFIRMATION_ALT2 : yesButton . requestFocus ( ) ; break ; case WARNING : okButton . requestFocus ( ) ; break ; case ERROR : okButton . requestFocus ( ) ; break ; case EXCEPTION : okButton . requestFocus ( ) ; break ; case INPUT_TEXT : inputTextField . requestFocus ( ) ; break ; case GENERIC_OK : okButton . requestFocus ( ) ; break ; case GENERIC_OK_CANCEL : okButton . requestFocus ( ) ; break ; case GENERIC_YES_NO : yesButton . requestFocus ( ) ; break ; case GENERIC_YES_NO_CANCEL : yesButton . requestFocus ( ) ; break ; } } } ) ; this . detailsLabel . setWrapText ( true ) ; this . headerLabel . setText ( getHeader ( ) ) ; this . detailsLabel . setText ( getDetails ( ) ) ; // Filter behaviour for exception dialog if ( dialogType == DialogType . EXCEPTION ) { this . exceptionArea . clear ( ) ; if ( this . exception != null ) { this . exceptionArea . appendText ( Arrays . toString ( this . exception . getStackTrace ( ) ) ) ; } else { this . exceptionArea . appendText ( DialogText . NO_EXCEPTION_TRACE . getText ( ) ) ; } this . exceptionArea . setWrapText ( true ) ; this . exceptionArea . setEditable ( false ) ; } // Filter whether it headless or not if ( this . dialogStyle == DialogStyle . HEADLESS ) { this . topBoxContainer . getChildren ( ) . remove ( this . headContainer ) ; this . setHeadlessPadding ( ) ; } // Apply Header CSS style color this . setHeaderColorStyle ( this . headerColorStyle ) ; }
Initializes the dialog . Sets default focus to OK button . Wraps the text for details message label and apply the user - defined header and details . Filter the behavior for the exception dialog for a null and non - null exception object given . Applies corresponding header background css style .