1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sourceforge.jhunters.pool.ui;
18
19 import javafx.collections.ObservableList;
20 import javafx.event.ActionEvent;
21 import javafx.event.EventHandler;
22 import javafx.geometry.Insets;
23 import javafx.geometry.Pos;
24 import javafx.scene.Node;
25 import javafx.scene.Scene;
26 import javafx.scene.control.Button;
27 import javafx.scene.control.Label;
28 import javafx.scene.layout.VBox;
29 import javafx.stage.Modality;
30 import javafx.stage.Stage;
31 import javafx.stage.StageStyle;
32
33
34
35
36 public class AboutBox extends Stage {
37
38
39
40 private static final String PROGRAM_TITLE = ProgramResource.TITLE.getValue();
41
42
43
44
45 private static final String PROMPT_VERSION = GuiResource.ABOUT_PROMPT_VERSION.getValue();
46
47
48
49
50 private static final String PROGRAM_VERSION = ProgramResource.VERSION.getValue();
51
52
53
54
55 private static final String PROMPT_REVISION = GuiResource.ABOUT_PROMPT_REVISION.getValue();
56
57
58
59
60 private static final String PROGRAM_REVISION = ProgramResource.REVISION.getValue();
61
62
63
64
65 private static final String PROMPT_BUILDDATE = GuiResource.ABOUT_PROMPT_BUILDDATE.getValue();
66
67
68
69
70 private static final String PROGRAM_BUILDDATE = ProgramResource.BUILDDATE.getValue();
71
72
73
74
75 private static final String PROGRAM_COPYRIGHT = ProgramResource.COPYRIGHT.getValue();
76
77
78
79
80 private static final String TEXT_OK = GuiResource.ABOUT_BUTTON_OK.getValue();
81
82
83
84
85 private static final int INSET_SIZE = 5;
86
87
88
89
90 private final Button theOKButton;
91
92
93
94
95
96 protected AboutBox(final Stage pStage) {
97
98 super(StageStyle.UNDECORATED);
99 initOwner(pStage);
100 initModality(Modality.WINDOW_MODAL);
101
102
103 Label myProduct = new Label(PROGRAM_TITLE);
104 Label myVersion = new Label(PROMPT_VERSION + " "
105 + PROGRAM_VERSION);
106 Label myRevision = new Label(PROMPT_REVISION + " "
107 + PROGRAM_REVISION);
108 Label myBuild = new Label(PROMPT_BUILDDATE + " "
109 + PROGRAM_BUILDDATE);
110 Label myCopyright = new Label(PROGRAM_COPYRIGHT);
111
112
113 theOKButton = new Button(TEXT_OK);
114 theOKButton.setMaxWidth(Double.MAX_VALUE);
115 theOKButton.setOnAction(new EventHandler<ActionEvent>() {
116 @Override
117 public void handle(final ActionEvent e) {
118 close();
119 }
120 });
121
122
123 VBox myPanel = new VBox();
124 myPanel.setAlignment(Pos.CENTER);
125 myPanel.setPadding(new Insets(INSET_SIZE, INSET_SIZE, INSET_SIZE, INSET_SIZE));
126 ObservableList<Node> myChildren = myPanel.getChildren();
127 myChildren.addAll(myProduct, myCopyright, new Label());
128 myChildren.addAll(myVersion, myRevision, myBuild, new Label());
129 myChildren.add(theOKButton);
130
131
132 myPanel.getStyleClass().add("-jht-about");
133
134
135 Scene myScene = new Scene(myPanel);
136 String myStylesheet = getClass().getResource("AboutBox.css").toExternalForm();
137 myScene.getStylesheets().add(myStylesheet);
138 setScene(myScene);
139 }
140 }