final
This commit is contained in:
45
Muehle.java
45
Muehle.java
@@ -19,6 +19,10 @@ import javafx.scene.layout.HBox;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.event.ActionEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* Beschreibung
|
||||
@@ -31,6 +35,8 @@ public class Muehle extends Application {
|
||||
// start attributes
|
||||
// end attributes
|
||||
private Label lTop = new Label();
|
||||
private Button restart_button;
|
||||
|
||||
private Pane game_board;
|
||||
private Game game;
|
||||
|
||||
@@ -38,16 +44,28 @@ public class Muehle extends Application {
|
||||
|
||||
|
||||
VBox root = new VBox();
|
||||
|
||||
|
||||
|
||||
game = new Game();
|
||||
|
||||
// lTop.setMaxWidth(1080);
|
||||
|
||||
HBox label_box = new HBox(lTop);
|
||||
label_box.setAlignment(Pos.CENTER);
|
||||
|
||||
lTop.setFont(Font.font("Roboto",FontWeight.BOLD,40));
|
||||
|
||||
|
||||
game_board = draw_game_board();
|
||||
root.getChildren().addAll(label_box,game_board);
|
||||
|
||||
restart_button = new Button("Restart");
|
||||
restart_button.setStyle("-fx-background-color: rgb(255,255,0); -fx-padding: 20px; -fx-text-fill: rgb(255,0,0);");
|
||||
|
||||
restart_button.addEventHandler(ActionEvent.ACTION, restart_event);
|
||||
|
||||
root.getChildren().addAll(label_box,game_board, restart_button);
|
||||
|
||||
// game_board.addEventHandler(KeyEvent.KEY_PRESSED, restart_event);
|
||||
|
||||
root.setStyle("-fx-background-color: rgb(255, 190, 0)");
|
||||
Scene scene = new Scene(root, 1080, 820);
|
||||
@@ -58,7 +76,7 @@ public class Muehle extends Application {
|
||||
drawPlayerChips();
|
||||
|
||||
//lTop.setAlignment();
|
||||
// setTopLabel("Test Label");
|
||||
// setTopLabel("Test Label");
|
||||
|
||||
|
||||
primaryStage.setOnCloseRequest(e -> System.exit(0));
|
||||
@@ -142,7 +160,7 @@ public class Muehle extends Application {
|
||||
return board;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void drawMuehleButtons(Pane board, double topLeftX,double topLeftY,double topRightX,double topRightY) {
|
||||
ArrayList<MuehleButton> buttons = new ArrayList<MuehleButton>();
|
||||
|
||||
@@ -185,7 +203,7 @@ public class Muehle extends Application {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
|
||||
MuehleButton button = new MuehleButton(id_count,topLeftX +200,topLeftY+ i*130 +200,game);
|
||||
id_count++;
|
||||
buttons.add(button);
|
||||
@@ -237,9 +255,14 @@ public class Muehle extends Application {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// end methods
|
||||
} // end of class Muehle
|
||||
public EventHandler<ActionEvent> restart_event = new EventHandler<ActionEvent>() {
|
||||
public void handle(ActionEvent event) {
|
||||
game.restart();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// end methods
|
||||
} // end of class Muehle
|
||||
|
||||
Reference in New Issue
Block a user