use of javafx.scene.control.Hyperlink in project POL-POM-5 by PlayOnLinux.
the class AboutPanel method populate.
private void populate() {
this.title = new TextWithStyle(tr("About"), "title");
this.aboutGrid = new GridPane();
this.aboutGrid.getStyleClass().add("grid");
this.aboutGrid.setHgap(20);
this.aboutGrid.setVgap(10);
this.nameDescription = new TextWithStyle(tr("Name:"), "captionTitle");
this.nameLabel = new Label(buildInformation.getApplicationName());
this.versionDescription = new TextWithStyle(tr("Version:"), "captionTitle");
this.versionLabel = new Label(buildInformation.getApplicationVersion());
this.gitRevisionDescription = new TextWithStyle(tr("Git Revision:"), "captionTitle");
this.gitRevisionHyperlink = new Hyperlink(buildInformation.getApplicationGitRevision());
this.gitRevisionHyperlink.setOnAction(event -> {
try {
URI uri = new URI("https://github.com/PlayOnLinux/POL-POM-5/commit/" + buildInformation.getApplicationGitRevision());
opener.open(uri);
} catch (URISyntaxException e) {
e.printStackTrace();
}
});
this.buildTimestampDescription = new TextWithStyle(tr("Build Timestamp:"), "captionTitle");
this.buildTimestampLabel = new Label(buildInformation.getApplicationBuildTimestamp());
this.aboutGrid.add(nameDescription, 0, 0);
this.aboutGrid.add(nameLabel, 1, 0);
this.aboutGrid.add(versionDescription, 0, 1);
this.aboutGrid.add(versionLabel, 1, 1);
this.aboutGrid.add(gitRevisionDescription, 0, 2);
this.aboutGrid.add(gitRevisionHyperlink, 1, 2);
this.aboutGrid.add(buildTimestampDescription, 0, 3);
this.aboutGrid.add(buildTimestampLabel, 1, 3);
}
use of javafx.scene.control.Hyperlink in project fx2048 by brunoborges.
the class Board method initGameProperties.
private void initGameProperties() {
overlay.setMinSize(gridWidth, gridWidth);
overlay.setAlignment(Pos.CENTER);
overlay.setTranslateY(TOP_HEIGHT + GAP_HEIGHT);
overlay.getChildren().setAll(txtOverlay);
txtOverlay.setAlignment(Pos.CENTER);
buttonsOverlay.setAlignment(Pos.CENTER);
buttonsOverlay.setTranslateY(TOP_HEIGHT + GAP_HEIGHT + gridWidth / 2);
buttonsOverlay.setMinSize(gridWidth, gridWidth / 2);
buttonsOverlay.setSpacing(10);
bTry.getStyleClass().add("game-button");
bTry.setOnTouchPressed(e -> btnTryAgain());
bTry.setOnAction(e -> btnTryAgain());
bTry.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
btnTryAgain();
}
});
bContinue.getStyleClass().add("game-button");
bContinue.setOnTouchPressed(e -> keepGoing());
bContinue.setOnMouseClicked(e -> keepGoing());
bContinue.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
keepGoing();
}
});
bContinueNo.getStyleClass().add("game-button");
bContinueNo.setOnTouchPressed(e -> keepGoing());
bContinueNo.setOnMouseClicked(e -> keepGoing());
bContinueNo.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
keepGoing();
}
});
bSave.getStyleClass().add("game-button");
bSave.setOnTouchPressed(e -> saveGame.set(true));
bSave.setOnMouseClicked(e -> saveGame.set(true));
bSave.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
saveGame.set(true);
}
});
bRestore.getStyleClass().add("game-button");
bRestore.setOnTouchPressed(e -> restoreGame.set(true));
bRestore.setOnMouseClicked(e -> restoreGame.set(true));
bRestore.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
restoreGame.set(true);
}
});
bQuit.getStyleClass().add("game-button");
bQuit.setOnTouchPressed(e -> quit());
bQuit.setOnMouseClicked(e -> quit());
bQuit.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER) || e.getCode().equals(KeyCode.SPACE)) {
quit();
}
});
timerPause = new Timeline(new KeyFrame(Duration.seconds(1), e -> time = time.plusNanos(1_000_000_000)));
timerPause.setCycleCount(Animation.INDEFINITE);
gameWonProperty.addListener(wonListener);
gameOverProperty.addListener(new Overlay("Game over!", "", bTry, null, "game-overlay-over", "game-lblOver", false));
gamePauseProperty.addListener(new Overlay("Game Paused", "", bContinue, null, "game-overlay-pause", "game-lblPause", true));
gameTryAgainProperty.addListener(new Overlay("Try Again?", "Current game will be deleted", bTry, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameSaveProperty.addListener(new Overlay("Save?", "Previous saved data will be overwritten", bSave, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameRestoreProperty.addListener(new Overlay("Restore?", "Current game will be deleted", bRestore, bContinueNo, "game-overlay-pause", "game-lblPause", true));
gameAboutProperty.addListener((observable, oldValue, newValue) -> {
if (newValue) {
timer.stop();
timerPause.play();
overlay.getStyleClass().setAll("game-overlay", "game-overlay-quit");
TextFlow flow = new TextFlow();
flow.setTextAlignment(TextAlignment.CENTER);
flow.setPadding(new Insets(10, 0, 0, 0));
flow.setMinSize(gridWidth, gridWidth);
flow.setPrefSize(gridWidth, gridWidth);
flow.setMaxSize(gridWidth, gridWidth);
flow.setPrefSize(BASELINE_OFFSET_SAME_AS_HEIGHT, BASELINE_OFFSET_SAME_AS_HEIGHT);
Text t00 = new Text("2048");
t00.getStyleClass().setAll("game-label", "game-lblAbout");
Text t01 = new Text("FX");
t01.getStyleClass().setAll("game-label", "game-lblAbout2");
Text t02 = new Text(" Game\n");
t02.getStyleClass().setAll("game-label", "game-lblAbout");
Text t1 = new Text("JavaFX game - Desktop version\n\n");
t1.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t20 = new Text("Powered by ");
t20.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link1 = new Hyperlink();
link1.setText("JavaFXPorts");
link1.setOnAction(e -> hostServices.showDocument("http://javafxports.org/page/home"));
link1.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t21 = new Text(" Project \n\n");
t21.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t23 = new Text("© ");
t23.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link2 = new Hyperlink();
link2.setText("@JPeredaDnr");
link2.setOnAction(e -> hostServices.showDocument("https://twitter.com/JPeredaDnr"));
link2.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t22 = new Text(" & ");
t22.getStyleClass().setAll("game-label", "game-lblAboutSub");
Hyperlink link3 = new Hyperlink();
link3.setText("@brunoborges");
link3.setOnAction(e -> hostServices.showDocument("https://twitter.com/brunoborges"));
Text t32 = new Text(" & ");
t32.getStyleClass().setAll("game-label", "game-lblAboutSub");
link3.getStyleClass().setAll("game-label", "game-lblAboutSub2");
Text t24 = new Text("\n\n");
t24.getStyleClass().setAll("game-label", "game-lblAboutSub");
Text t31 = new Text(" Version " + Game2048.VERSION + " - 2015\n\n");
t31.getStyleClass().setAll("game-label", "game-lblAboutSub");
flow.getChildren().setAll(t00, t01, t02, t1, t20, link1, t21, t23, link2, t22, link3);
flow.getChildren().addAll(t24, t31);
txtOverlay.getChildren().setAll(flow);
buttonsOverlay.getChildren().setAll(bContinue);
this.getChildren().removeAll(overlay, buttonsOverlay);
this.getChildren().addAll(overlay, buttonsOverlay);
layerOnProperty.set(true);
}
});
gameQuitProperty.addListener(new Overlay("Quit Game?", "Non saved data will be lost", bQuit, bContinueNo, "game-overlay-quit", "game-lblQuit", true));
restoreRecord();
gameScoreProperty.addListener((ov, i, i1) -> {
if (i1.intValue() > gameBestProperty.get()) {
gameBestProperty.set(i1.intValue());
}
});
layerOnProperty.addListener((ov, b, b1) -> {
if (!b1) {
getChildren().removeAll(overlay, buttonsOverlay);
// Keep the focus on the game when the layer is removed:
getParent().requestFocus();
} else if (b1) {
// Set focus on the first button
buttonsOverlay.getChildren().get(0).requestFocus();
}
});
}
Aggregations