ClickEvent StartButton
This commit is contained in:
parent
2897dfd341
commit
882baf19af
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,10 +5,4 @@
|
||||
|
||||
<StackPane prefHeight="800.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.happy_bird.HappyBird" back >
|
||||
|
||||
<ImageView>
|
||||
<image>
|
||||
<Image url="@pics/Background.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
|
||||
</StackPane>
|
||||
|
Binary file not shown.
@ -1,12 +1,15 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
@ -24,9 +27,9 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
Pane stackPane = new Pane();
|
||||
Pane pane = new Pane();
|
||||
|
||||
Scene scene = new Scene(stackPane, 800, 700);
|
||||
Scene scene = new Scene(pane, 800, 700);
|
||||
stage.setTitle("Happy Bird");
|
||||
stage.setScene(scene);
|
||||
|
||||
@ -40,12 +43,12 @@ public class HappyBirdMain extends Application {
|
||||
);
|
||||
|
||||
Background background = new Background(backgroundImageImg);
|
||||
stackPane.setBackground(background);
|
||||
pane.setBackground(background);
|
||||
|
||||
Label label = new Label("Happy Bird");
|
||||
label.setPrefSize(300, 75);
|
||||
label.setTextAlignment(TextAlignment.CENTER);
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
Label headline = new Label("Happy Bird");
|
||||
headline.setPrefSize(300, 75);
|
||||
headline.setTextAlignment(TextAlignment.CENTER);
|
||||
headline.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
@ -54,20 +57,21 @@ public class HappyBirdMain extends Application {
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
label.setLayoutX(250);
|
||||
label.setLayoutY(100);
|
||||
headline.setLayoutX(250);
|
||||
headline.setLayoutY(100);
|
||||
|
||||
stackPane.getChildren().addAll(label);
|
||||
pane.getChildren().addAll(headline);
|
||||
|
||||
Button startButton = new Button("START");
|
||||
Button highscoresButton = new Button("HIGHSCORES");
|
||||
Button einstellungsButton = new Button("EINSTELLUNGEN");
|
||||
Button settingsButton = new Button("EINSTELLUNGEN");
|
||||
Button spielStarten = new Button("SPIEL STARTEN");
|
||||
|
||||
Button buttons[] = {startButton, highscoresButton, einstellungsButton};
|
||||
Button buttons[] = {startButton, highscoresButton, settingsButton, spielStarten};
|
||||
|
||||
int yPosition = 225;
|
||||
for (Button button : buttons) {
|
||||
stackPane.getChildren().add(button);
|
||||
pane.getChildren().add(button);
|
||||
button.setPrefSize(200, 50);
|
||||
button.setLayoutX(300);
|
||||
button.setLayoutY(yPosition);
|
||||
@ -83,6 +87,70 @@ public class HappyBirdMain extends Application {
|
||||
"-fx-background-radius: 20px;");
|
||||
}
|
||||
|
||||
spielStarten.setVisible(false);
|
||||
|
||||
startButton.setOnAction(event -> {
|
||||
headline.setText("Start");
|
||||
for(Button button : buttons) {
|
||||
button.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
Label nameLabel = new Label("Name:");
|
||||
Label acronymLabel = new Label("Kürzel:");
|
||||
|
||||
Label startLabels[] = {nameLabel, acronymLabel};
|
||||
|
||||
int yPositionStartLabels = 225;
|
||||
for(Label label : startLabels) {
|
||||
label.setPrefSize(250, 50);
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
label.setLayoutX(275);
|
||||
label.setLayoutY(yPositionStartLabels);
|
||||
yPositionStartLabels += 150;
|
||||
|
||||
pane.getChildren().add(label);
|
||||
}
|
||||
|
||||
TextField name = new TextField();
|
||||
TextField acronym = new TextField();
|
||||
|
||||
TextField inputFields[] = {name, acronym};
|
||||
|
||||
int yPositionInputFields = 290;
|
||||
for(TextField feld : inputFields) {
|
||||
feld.setPrefSize(250, 50);
|
||||
feld.setStyle("-fx-font-size: 20px;" +
|
||||
"-fx-font-weight: bold;");
|
||||
|
||||
feld.setLayoutX(275);
|
||||
feld.setLayoutY(yPositionInputFields);
|
||||
yPositionInputFields += 150;
|
||||
|
||||
pane.getChildren().add(feld);
|
||||
}
|
||||
|
||||
spielStarten.setVisible(true);
|
||||
|
||||
spielStarten.setLayoutY(520);
|
||||
});
|
||||
|
||||
|
||||
startButton.setOnAction(event -> {
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
stage.show();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,4 @@
|
||||
|
||||
<StackPane prefHeight="800.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.happy_bird.HappyBird" back >
|
||||
|
||||
<ImageView>
|
||||
<image>
|
||||
<Image url="@pics/Background.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
|
||||
</StackPane>
|
||||
|
Loading…
Reference in New Issue
Block a user