Exemplo n.º 1
0
  public void initContent(GridPane pane) {
    // pane.setGridLinesVisible(true);
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(20);

    // header label
    Label lblHeader = new Label("Alert Dialogs");
    pane.add(lblHeader, 1, 0);
    lblHeader.setTextFill(Color.DARKBLUE);
    lblHeader.setFont(Font.font("Calibri", FontWeight.BOLD, 36));

    // label for input text field
    Label lblInput = new Label("A Text field:");
    pane.add(lblInput, 0, 1);
    lblInput.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));

    // input text field
    this.txfInput = new TextField();
    pane.add(txfInput, 1, 1);
    this.txfInput.setMinHeight(30.0);
    this.txfInput.setPromptText("Enter some text and save.");

    // horizontal box for buttons
    HBox hbox = new HBox(20);
    pane.add(hbox, 1, 2);
    hbox.setAlignment(Pos.CENTER);

    // info button
    Button btnInfo = new Button("Info");
    btnInfo.setOnAction(event -> this.infoAction());
    hbox.getChildren().add(btnInfo);

    // save button
    Button btnSave = new Button("Save");
    btnSave.setOnAction(event -> this.saveAction());
    hbox.getChildren().add(btnSave);

    // clear button
    Button btnClear = new Button("Clear");
    btnClear.setOnAction(event -> this.clearAction());
    hbox.getChildren().add(btnClear);

    // status text
    this.txtStatus = new Text();
    pane.add(txtStatus, 0, 4, 3, 1);
    this.txtStatus.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));
    this.txtStatus.setFill(Color.FIREBRICK);
    this.txtStatus.setText("An example of Alert Dialogs. Enter some text and save.");

    btnInfo.requestFocus();
  }
Exemplo n.º 2
0
 @FXML
 private void initialize() {
   LogHandler.initialize(textArea);
   ScriptManager.instance().setAlert((str) -> alert(str));
   ScriptManager.instance().setConfirm((str) -> confirm(str));
   ScriptManager.instance().setPrompt((str, defValue) -> prompt(str, defValue));
   ScriptManager.instance().setSelect((str, options) -> select(str, options));
   model.initialize(() -> autoAdjustResolution(), () -> updateUI());
   initHeader();
   initFooter();
   initSettingsPane();
   updateUI();
   startButton.requestFocus();
 }
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    player = GameController.getGameData().getPlayer();
    dailyCost = 0;
    selectedSkill = pilot_button;
    pilot_button.requestFocus();

    checkForHire();

    Button[] buttons = {
      pilot_button, fighter_button, engineer_button, trader_button, investor_button
    };
    for (Button b : buttons) {
      b.setOnMouseClicked(
          (MouseEvent t) -> {
            selectedSkill = b;
            generateCostAndStat();
          });
    }

    name_field.addEventFilter(
        KeyEvent.KEY_TYPED,
        (KeyEvent event) -> {
          if (name_field.getText().length() >= 18) {
            event.consume();
          }
        });

    power_slider
        .valueProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> {
              generateCostAndStat();
            });

    hire_button.setOnMouseClicked(
        (MouseEvent t) -> {
          Mercenary merc =
              new Mercenary(name_field.getText(), selectedSkill.getText(), power, dailyCost);
          player.getShip().addCrew(merc);
          checkForHire();
        });
  }
Exemplo n.º 4
0
 @FXML
 public void handleStopButtonAction() {
   model.stop();
   startButton.requestFocus();
 }