Skip to content
Snippets Groups Projects
Select Git revision
  • bd33477205396c78128bfda692d29ca1e7241253
  • master default protected
2 results

lambda.scala

Blame
  • Forked from joel.cavat / scala2020
    Source project has a limited visibility.
    AskForBetController.java 947 B
    package hepia;
    
    import javafx.fxml.FXML;
    import javafx.scene.control.Button;
    import javafx.scene.control.TextField;
    import javafx.stage.Stage;
    
    public class AskForBetController extends BlackJackController {
        @FXML
        private TextField inputBet;
        @FXML
        private Button btnSetBet;
    
        @FXML
        public void initialize() {
            filterInputs(inputBet);
    
            btnSetBet.disableProperty().bind(inputBet.textProperty().isEmpty());
        }
    
        private void filterInputs(TextField inputField) {
            inputField.addEventFilter(javafx.scene.input.KeyEvent.KEY_TYPED, event -> {
                if (!event.getCharacter().matches("[0-9]")) {
                    event.consume();
                }
            });
        }
    
        @FXML
        protected void setHumanBet() {
            Stage currentStage = (Stage) btnSetBet.getScene().getWindow();
            currentStage.close();
    
            humanPlayers.add(new HumanPlayer(Integer.parseInt(inputBet.getText())));
        }
    }