天天看點

java setPadding屬性_Java Button.setPadding方法代碼示例

import javafx.scene.control.Button; //導入方法依賴的package包/類

public VBox setRightBlock(){

VBox jobb = new VBox(10);

jobb.setSpacing(10);

jobb.setPrefWidth(200);

jobb.setPrefHeight(500);

jobb.setLayoutX(WIDTH-200);

Button gomb = new Button("Játék újrakezdése");

gomb.setPrefWidth(150);

gomb.setPadding(new Insets(10, 10, 10, 10));

gomb.setTranslateX((jobb.getPrefWidth()-gomb.getPrefWidth())/2);

gomb.setTranslateY(50);

jobb.setStyle("-fx-background-color: #c2c2d6;");

jobb.getChildren().add(gomb);

Text manualTitle = new Text("Irányítás:");

manualTitle.setTranslateX(50);

manualTitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

manualTitle.setTranslateY(100);

jobb.getChildren().add(manualTitle);

GridPane moveHolder = new GridPane();

moveHolder.setAlignment(Pos.CENTER);

moveHolder.setHgap(10);

moveHolder.setVgap(10);

moveHolder.setPrefWidth(200);

moveHolder.setPrefHeight(400);

Text moveUp = new Text("↑ - Felfele lépés");

moveUp.setTextAlignment(TextAlignment.CENTER);

moveUp.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

moveHolder.add(moveUp, 0, 0, 2, 1);

Text moveDown = new Text("↓ - Lefele lépés");

moveDown.setTextAlignment(TextAlignment.CENTER);

moveDown.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

moveHolder.add(moveDown, 0, 1, 2, 1);

Text moveLeft = new Text("← - Balra lépés");

moveLeft.setTextAlignment(TextAlignment.CENTER);

moveLeft.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

moveHolder.add(moveLeft, 0, 2, 2, 1);

Text moveRight = new Text("→ - Jobbra lépés");

moveRight.setTextAlignment(TextAlignment.CENTER);

moveRight.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));

moveHolder.add(moveRight, 0, 3, 2, 1);

jobb.getChildren().add(moveHolder);

gomb.setOnAction(new EventHandler() {

@Override public void handle(ActionEvent e) {

playGround.lepes = 0;

playGround.celban = 0;

playGround.getDatum();

playGround.resetPlayGround();

updatePlayGround();

playGround.nyertes = 0;

playGround.kezdes = 1;

}

});

return jobb;

}