コード例 #1
0
ファイル: GameMessages.java プロジェクト: johnbrovi/cpp_labs
  /**
   * Method provides opening of game over menu. It will display player score and offer to user for
   * score saving.
   *
   * @param score - player score.
   */
  public void openGameOverMessage(Integer score) {
    setTranslateX(300);
    setTranslateY(110);
    setPrefSize(400, 340);

    gameOverMenu.setTranslateX(60);
    gameOverMenu.setTranslateY(220);
    gameOverMenu.setStyle("-fx-background-color: grey;");

    gameOverMessageBlock.setWidth(400);
    gameOverMessageBlock.setHeight(340);
    gameOverMessageBlock.setArcWidth(30);
    gameOverMessageBlock.setArcHeight(30);
    gameOverMessageBlock.setOpacity(0.7);

    gameOverMessage.setTranslateX(105);
    gameOverMessage.setTranslateY(65);
    gameOverMessage.setFill(Color.RED);
    gameOverMessage.setFont(Font.loadFont(GameFiles.SENSEI, 40));
    gameOverMessage.setText("GAME OVER");

    gameOverScore.setTranslateX(100);
    gameOverScore.setTranslateY(95);
    gameOverScore.setFill(Color.WHITE);
    gameOverScore.setTextAlignment(TextAlignment.CENTER);
    gameOverScore.setFont(Font.loadFont(GameFiles.SENSEI, 24));
    gameOverScore.setText("Your score:\n" + score.toString() + "\nEnter your name:");

    playerName.setTranslateX(79);
    playerName.setTranslateY(170);
    playerName.setEditable(true);
    playerName.setFont(Font.loadFont(GameFiles.SENSEI, 20));
    playerName.setPrefSize(240, 40);
    playerName.setStyle("-fx-background-color: grey;");

    gameOverBox
        .getChildren()
        .addAll(gameOverMessageBlock, gameOverMessage, gameOverScore, playerName, gameOverMenu);

    getChildren().add(gameOverBox);
    return;
  }
コード例 #2
0
 public NameDialog(final Stage stg, Maze maze) {
   width = 350;
   height = 80;
   this.maze = maze;
   stage = new Stage();
   stage.initModality(Modality.APPLICATION_MODAL);
   stage.initOwner(stg);
   stage.setTitle("Name:Press Enter Confirmed");
   Group root = new Group();
   AnchorPane anchorPane = new AnchorPane();
   okbtn = new Button("确定");
   field = new TextField();
   field.setFont(new Font(30));
   field.setPrefWidth(width);
   field.setPrefHeight(height);
   property.set(false);
   MyEvent myEvent = new MyEvent();
   field.setOnKeyPressed(
       new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent event) {
           if (event.getCode() == KeyCode.ENTER) {
             maze.handleEvent(field.getText());
             stage.close();
           }
         }
       });
   okbtn.setOnMouseClicked(myEvent);
   Scene scene = new Scene(root, width, height + 20);
   anchorPane.getChildren().add(field);
   okbtn.setLayoutX(0);
   okbtn.setLayoutY(height);
   anchorPane.getChildren().add(okbtn);
   root.getChildren().add(anchorPane);
   stage.setScene(scene);
   stage.show();
 }
コード例 #3
0
ファイル: Jar.java プロジェクト: jkralicky/JNIBuilder
  public static void setJar(final Tile node) {
    node.data.put("type", "Jar");
    List<Node> toRemove = new ArrayList<>();
    for (Node n : node.node.getChildren()) {
      if (!n.getId().equals("delete")) {
        if (n.getId().equals("typeLabel")) {
          Label l = (Label) n;
          l.setText("jar");
          l.setTranslateY(l.getTranslateY() - 1);
        } else {
          toRemove.add(n);
        }
      }
    }

    VBox leftPadding = new VBox();
    leftPadding.setPrefWidth(14);
    VBox buttons = new VBox();
    VBox textBoxes = new VBox();
    VBox extra = new VBox();

    buttons.setSpacing(5);
    textBoxes.setSpacing(5);
    extra.setSpacing(5);

    buttons.setPadding(new Insets(7, 0, 0, 0));
    textBoxes.setPadding(new Insets(7, 0, 0, 0));
    extra.setPadding(new Insets(7, 0, 0, 0));

    textBoxes.setTranslateX(17);
    extra.setTranslateX(32);

    node.node.getChildren().removeAll(toRemove);

    final String name = "Package Name";
    final String name2 = "Jar Name";

    Button findPkg = new Button();
    final TextField pkgText = new TextField();
    final TextField jarName = new TextField();

    findPkg.getStyleClass().add("defaultButton");
    findPkg.setText("Find Package Name");
    findPkg.setPrefHeight(25);
    findPkg.setTranslateX(12);

    findPkg.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            String mainClassName = Util.packageNameFromTile();
            if (mainClassName != null) {
              pkgText.setText(mainClassName);
            }
          }
        });

    pkgText.setText(name);
    pkgText.setPrefSize(150, 27);
    pkgText.setFont(Font.font("Segoe UI"));
    pkgText.setId("textBox");
    pkgText
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("package", pkgText.getText().trim());
              }
            });
    pkgText
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && pkgText.getText().equals(name)) {
                  pkgText.setText("");
                } else if (newValue == false && pkgText.getText().trim().equals("")) {
                  pkgText.setText(name);
                }
              }
            });

    jarName.setText(name2);
    jarName.setPrefSize(150, 27);
    jarName.setFont(Font.font("Segoe UI"));
    jarName.setId("textBox");
    jarName
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("jarname", jarName.getText().trim());
              }
            });
    jarName
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && jarName.getText().equals(name2)) {
                  jarName.setText("");
                } else if (newValue == false && jarName.getText().trim().equals("")) {
                  jarName.setText(name2);
                }
              }
            });

    final String defTxt = "Additional Flags";
    final TextField flags = new TextField();
    flags.setText(defTxt);
    flags.setPrefSize(150, 27);
    flags.setFont(Font.font("Segoe UI"));
    flags.setId("textBox");

    flags
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && flags.getText().equals(defTxt)) {
                  flags.setText("");
                } else if (newValue == false && flags.getText().trim().equals("")) {
                  flags.setText(defTxt);
                }
              }
            });
    flags
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("flags", flags.getText().trim());
              }
            });

    final String defTxt2 = "Output Directory";
    final TextField outputDir = new TextField();
    outputDir.setText(defTxt2);
    outputDir.setPrefSize(150, 27);
    outputDir.setFont(Font.font("Segoe UI"));
    outputDir.setId("textBox");

    outputDir
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && outputDir.getText().equals(defTxt2)) {
                  outputDir.setText("");
                } else if (newValue == false && outputDir.getText().trim().equals("")) {
                  outputDir.setText(defTxt2);
                }
              }
            });
    outputDir
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("output", outputDir.getText().trim());
              }
            });

    buttons.getChildren().addAll(findPkg);
    textBoxes.getChildren().addAll(pkgText, jarName);
    extra.getChildren().addAll(flags, outputDir);
    node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra);
  }