src/authoring/gamestate/GameNameChooser.java
@Override
	public void showAndWait(Consumer<String> onClose) {
		Stage stage = new Stage();
		Scene scene = new Scene(root, SCREEN_WIDTH, SCREEN_HEIGHT);
		scene.getStylesheets().add(MainApplication.class.getResource("styles.css").toExternalForm());
		root.getStyleClass().add(BACKGROUND_CSS);
		ElementFactory ef = new ElementFactory();
		try {
			field = (TextField) ef.buildElement(ElementType.TextField, PROMPT);
			field.setMaxWidth(TEXT_WIDTH);
			Label label = new Label(LABEL_TEXT);
			label.getStyleClass().add(LABEL_CSS);
			root.getChildren().addAll(label, field);
			field.getStyleClass().add(TEXT_FIELD_CSS);
		} catch (Exception e) {
			throw new AuthoringException(e, AuthoringAlert.NO_SHOW);
		}
		stage.setTitle(PROMPT);
		stage.setScene(scene);
		stage.show();
		stage.centerOnScreen();
		scene.addEventHandler(KeyEvent.KEY_PRESSED, key -> {
			if (key.getCode().equals(KeyCode.ENTER)) {
				if (!(field.getText() == null || field.getText().trim().isEmpty())) {
					DataUtils.setGame(field.getText());
					onClose.accept(field.getText());
					stage.close();
				} else {
					throw new AuthoringException(ERROR_MESSAGE, AuthoringAlert.SHOW);
				}
			}	
		});
	}
/**
	 * Show this pop-up by adding the necessary JavaFX elements.
	 */
Show this pop-up by adding the necessary JavaFX elements.
Show this pop - up by adding the necessary JavaFX elements .
@Override
	public void showAndWait(Consumer<String> onClose) {
		Stage stage = new Stage();
		Scene scene = new Scene(root, SCREEN_WIDTH, SCREEN_HEIGHT);
		scene.getStylesheets().add(MainApplication.class.getResource("styles.css").toExternalForm());
		root.getStyleClass().add(BACKGROUND_CSS);
		ElementFactory ef = new ElementFactory();
		try {
			field = (TextField) ef.buildElement(ElementType.TextField, PROMPT);
			field.setMaxWidth(TEXT_WIDTH);
			Label label = new Label(LABEL_TEXT);
			label.getStyleClass().add(LABEL_CSS);
			root.getChildren().addAll(label, field);
			field.getStyleClass().add(TEXT_FIELD_CSS);
		} catch (Exception e) {
			throw new AuthoringException(e, AuthoringAlert.NO_SHOW);
		}
		stage.setTitle(PROMPT);
		stage.setScene(scene);
		stage.show();
		stage.centerOnScreen();
		scene.addEventHandler(KeyEvent.KEY_PRESSED, key -> {
			if (key.getCode().equals(KeyCode.ENTER)) {
				if (!(field.getText() == null || field.getText().trim().isEmpty())) {
					DataUtils.setGame(field.getText());
					onClose.accept(field.getText());
					stage.close();
				} else {
					throw new AuthoringException(ERROR_MESSAGE, AuthoringAlert.SHOW);
				}
			}	
		});
	}
@ Override public void showAndWait ( Consumer < String > onClose ) { Stage stage = new Stage ( ) ; Scene scene = new Scene ( root , SCREEN_WIDTH , SCREEN_HEIGHT ) ; scene . getStylesheets ( ) . add ( MainApplication . class . getResource ( "styles.css" ) . toExternalForm ( ) ) ; root . getStyleClass ( ) . add ( BACKGROUND_CSS ) ; ElementFactory ef = new ElementFactory ( ) ; try { field = ( TextField ) ef . buildElement ( ElementType . TextField , PROMPT ) ; field . setMaxWidth ( TEXT_WIDTH ) ; Label label = new Label ( LABEL_TEXT ) ; label . getStyleClass ( ) . add ( LABEL_CSS ) ; root . getChildren ( ) . addAll ( label , field ) ; field . getStyleClass ( ) . add ( TEXT_FIELD_CSS ) ; } catch ( Exception e ) { throw new AuthoringException ( e , AuthoringAlert . NO_SHOW ) ; } stage . setTitle ( PROMPT ) ; stage . setScene ( scene ) ; stage . show ( ) ; stage . centerOnScreen ( ) ; scene . addEventHandler ( KeyEvent . KEY_PRESSED , key -> { if ( key . getCode ( ) . equals ( KeyCode . ENTER ) ) { if ( ! ( field . getText ( ) == null || field . getText ( ) . trim ( ) . isEmpty ( ) ) ) { DataUtils . setGame ( field . getText ( ) ) ; onClose . accept ( field . getText ( ) ) ; stage . close ( ) ; } else { throw new AuthoringException ( ERROR_MESSAGE , AuthoringAlert . SHOW ) ; } } } ) ; }
Show this pop-up by adding the necessary JavaFX elements.
Show this pop - up by adding the necessary JavaFX elements .