Buttons und Label Startmenü
This commit is contained in:
parent
c070a72d91
commit
2897dfd341
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.
Binary file not shown.
@ -3,12 +3,17 @@ package com.example.happy_bird;
|
||||
import javafx.application.Application;
|
||||
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.image.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.*;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class HappyBirdMain extends Application {
|
||||
@ -19,17 +24,12 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
/*FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("happyBird.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 800, 700);
|
||||
stage.setTitle("HappyBird");
|
||||
stage.setScene(scene);
|
||||
stage.show();*/
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
Pane stackPane = new Pane();
|
||||
|
||||
Scene scene = new Scene(stackPane, 800, 700);
|
||||
stage.setTitle("Happy Bird");
|
||||
stage.setScene(scene);
|
||||
|
||||
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background.png");
|
||||
BackgroundImage backgroundImageImg = new BackgroundImage(
|
||||
image,
|
||||
@ -41,7 +41,48 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
Background background = new Background(backgroundImageImg);
|
||||
stackPane.setBackground(background);
|
||||
|
||||
|
||||
Label label = new Label("Happy Bird");
|
||||
label.setPrefSize(300, 75);
|
||||
label.setTextAlignment(TextAlignment.CENTER);
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-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(250);
|
||||
label.setLayoutY(100);
|
||||
|
||||
stackPane.getChildren().addAll(label);
|
||||
|
||||
Button startButton = new Button("START");
|
||||
Button highscoresButton = new Button("HIGHSCORES");
|
||||
Button einstellungsButton = new Button("EINSTELLUNGEN");
|
||||
|
||||
Button buttons[] = {startButton, highscoresButton, einstellungsButton};
|
||||
|
||||
int yPosition = 225;
|
||||
for (Button button : buttons) {
|
||||
stackPane.getChildren().add(button);
|
||||
button.setPrefSize(200, 50);
|
||||
button.setLayoutX(300);
|
||||
button.setLayoutY(yPosition);
|
||||
yPosition += 100;
|
||||
|
||||
button.setStyle("-fx-background-color: #e86000; " +
|
||||
"-fx-text-fill: #FFFFFF; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #FFFFFF;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
}
|
||||
|
||||
stage.show();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user