-
Notifications
You must be signed in to change notification settings - Fork 2
/
Menu.java
60 lines (51 loc) · 1.54 KB
/
Menu.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.effect.Reflection;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
public class Menu extends StackPane
{
private ImageView backgroundView=new ImageView("Tetris.jpg");
private Label label=createLabel();
private Button startButton=createStartButton();
private Menu()
{
VBox vBox=new VBox();
vBox.getChildren().addAll(label,startButton);
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(120);
getChildren().addAll(backgroundView,vBox);
}
private static class HolderClass
{
private final static Menu instance=new Menu();
}
public static Menu getInstance()
{
return HolderClass.instance;
}
private Label createLabel()
{
Label label=new Label("Tetris");
label.setFont(Font.font("Times New Roman", FontWeight.BOLD, FontPosture.REGULAR,64));
Reflection reflection=new Reflection();
reflection.setFraction(0.7);
label.setEffect(reflection);
return label;
}
private Button createStartButton()
{
ImageView imageView=new ImageView("startButton.png");
Button button=new Button("开始游戏",imageView);
return button;
}
public Button getStartButton()
{
return startButton;
}
}