|
1 |
| -/* |
2 |
| - * Copyright 2019 George Tzikas <[email protected]> |
3 |
| - * |
4 |
| - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
| - * you may not use this file except in compliance with the License. |
6 |
| - * You may obtain a copy of the License at |
7 |
| - * |
8 |
| - * http://www.apache.org/licenses/LICENSE-2.0 |
9 |
| - * |
10 |
| - * Unless required by applicable law or agreed to in writing, software |
11 |
| - * distributed under the License is distributed on an "AS IS" BASIS, |
12 |
| - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
| - * See the License for the specific language governing permissions and |
14 |
| - * limitations under the License. |
15 |
| - */ |
16 |
| -package assignment2application4; |
17 |
| - |
18 |
| -import java.util.ArrayList; |
19 |
| -import java.util.List; |
20 |
| -import javafx.application.Application; |
21 |
| -import javafx.geometry.HPos; |
22 |
| -import javafx.geometry.Insets; |
23 |
| -import javafx.geometry.Pos; |
24 |
| -import javafx.scene.Scene; |
25 |
| -import javafx.scene.control.Button; |
26 |
| -import javafx.scene.control.Label; |
27 |
| -import javafx.scene.control.TextField; |
28 |
| -import javafx.scene.layout.GridPane; |
29 |
| -import javafx.stage.Stage; |
30 |
| - |
31 |
| -/** |
32 |
| - * |
33 |
| - * @author tzikas97 |
34 |
| - */ |
35 |
| -public class Assignment2Application4 extends Application { |
36 |
| - |
37 |
| - /** |
38 |
| - * |
39 |
| - * @param firstStage The application's first stage |
40 |
| - */ |
41 |
| - @Override |
42 |
| - public void start(Stage firstStage) { |
43 |
| - |
44 |
| - firstStage.setTitle("Assignment2Application4"); |
45 |
| - |
46 |
| - // Load labels in a list |
47 |
| - List<Label> labelsList = new ArrayList<>(); |
48 |
| - |
49 |
| - // Load textfields in a list |
50 |
| - List<TextField> textFieldsList = new ArrayList<>(); |
51 |
| - |
52 |
| - labelsList.add(new Label("First Name:")); |
53 |
| - labelsList.add(new Label("Initials:")); |
54 |
| - labelsList.add(new Label("Last Name:")); |
55 |
| - |
56 |
| - for (int i = 0; i < 3; i++) { |
57 |
| - textFieldsList.add(new TextField()); |
58 |
| - } |
59 |
| - textFieldsList.get(0).setPromptText("Μικρό όνομα"); |
60 |
| - textFieldsList.get(1).setPromptText("Αρχικά (Mr/Mrs/Miss)"); |
61 |
| - textFieldsList.get(2).setPromptText("Επώνυμο"); |
62 |
| - |
63 |
| - Button submitButton = new Button("Submit"); |
64 |
| - |
65 |
| - GridPane pane = new GridPane(); |
66 |
| - |
67 |
| - // Layout options |
68 |
| - pane.setPadding(new Insets(10, 10, 10, 10)); |
69 |
| - pane.setVgap(10); |
70 |
| - pane.setHgap(10); |
71 |
| - pane.setAlignment(Pos.CENTER); |
72 |
| - GridPane.setHalignment(submitButton, HPos.RIGHT); |
73 |
| - |
74 |
| - for (int i = 0; i < 3; i++) { |
75 |
| - pane.add(labelsList.get(i), 0, i); |
76 |
| - pane.add(textFieldsList.get(i), 1, i); |
77 |
| - } |
78 |
| - |
79 |
| - pane.add(submitButton, 1, 3); |
80 |
| - |
81 |
| - Scene scene = new Scene(pane, 350, 350); |
82 |
| - |
83 |
| - firstStage.setScene(scene); |
84 |
| - firstStage.show(); |
85 |
| - } |
86 |
| - |
87 |
| - /** |
88 |
| - * |
89 |
| - * @param args The command line arguments |
90 |
| - */ |
91 |
| - public static void main(String[] args) { |
92 |
| - Application.launch(args); |
93 |
| - } |
94 |
| - |
95 |
| -} |
| 1 | +/* |
| 2 | + * Copyright 2019 George Tzikas <[email protected]> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package assignment2application4; |
| 17 | + |
| 18 | +import java.util.ArrayList; |
| 19 | +import java.util.List; |
| 20 | +import javafx.application.Application; |
| 21 | +import javafx.geometry.HPos; |
| 22 | +import javafx.geometry.Insets; |
| 23 | +import javafx.geometry.Pos; |
| 24 | +import javafx.scene.Scene; |
| 25 | +import javafx.scene.control.Button; |
| 26 | +import javafx.scene.control.Label; |
| 27 | +import javafx.scene.control.TextField; |
| 28 | +import javafx.scene.layout.GridPane; |
| 29 | +import javafx.stage.Stage; |
| 30 | + |
| 31 | +/** |
| 32 | + * |
| 33 | + * @author tzikas97 |
| 34 | + */ |
| 35 | +public class Assignment2Application4 extends Application { |
| 36 | + |
| 37 | + /** |
| 38 | + * |
| 39 | + * @param firstStage The application's first stage |
| 40 | + */ |
| 41 | + @Override |
| 42 | + public void start(Stage firstStage) { |
| 43 | + |
| 44 | + firstStage.setTitle("Assignment2Application4"); |
| 45 | + |
| 46 | + // Store labels in a list |
| 47 | + List<Label> labelsList = new ArrayList<>(); |
| 48 | + |
| 49 | + // Store textfields in a list |
| 50 | + List<TextField> textFieldsList = new ArrayList<>(); |
| 51 | + |
| 52 | + labelsList.add(new Label("First Name:")); |
| 53 | + labelsList.add(new Label("Initials:")); |
| 54 | + labelsList.add(new Label("Last Name:")); |
| 55 | + |
| 56 | + for (int i = 0; i < 3; i++) { |
| 57 | + textFieldsList.add(new TextField()); |
| 58 | + } |
| 59 | + textFieldsList.get(0).setPromptText("Μικρό όνομα"); |
| 60 | + textFieldsList.get(1).setPromptText("Αρχικά (Mr/Mrs/Miss)"); |
| 61 | + textFieldsList.get(2).setPromptText("Επώνυμο"); |
| 62 | + |
| 63 | + Button submitButton = new Button("Submit"); |
| 64 | + |
| 65 | + GridPane pane = new GridPane(); |
| 66 | + |
| 67 | + // Layout options |
| 68 | + pane.setPadding(new Insets(10, 10, 10, 10)); |
| 69 | + pane.setVgap(10); |
| 70 | + pane.setHgap(10); |
| 71 | + pane.setAlignment(Pos.CENTER); |
| 72 | + GridPane.setHalignment(submitButton, HPos.RIGHT); |
| 73 | + |
| 74 | + for (int i = 0; i < 3; i++) { |
| 75 | + pane.add(labelsList.get(i), 0, i); |
| 76 | + pane.add(textFieldsList.get(i), 1, i); |
| 77 | + } |
| 78 | + |
| 79 | + pane.add(submitButton, 1, 3); |
| 80 | + |
| 81 | + Scene scene = new Scene(pane, 350, 350); |
| 82 | + |
| 83 | + firstStage.setScene(scene); |
| 84 | + firstStage.show(); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * |
| 89 | + * @param args The command line arguments |
| 90 | + */ |
| 91 | + public static void main(String[] args) { |
| 92 | + Application.launch(args); |
| 93 | + } |
| 94 | + |
| 95 | +} |
0 commit comments