HelloWorldFXController.java
1 |
/*-------------------------------------------------------------------------+
|
---|---|
2 |
| Copyright 2019 fortiss GmbH |
|
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 org.fortiss.af3.exploration.ui.playground; |
17 |
|
18 |
import static java.lang.String.format; |
19 |
|
20 |
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase; |
21 |
import org.fortiss.tooling.common.ui.javafx.layout.ICompositeFXController; |
22 |
|
23 |
import javafx.fxml.FXML; |
24 |
import javafx.scene.control.Button; |
25 |
import javafx.scene.control.Label; |
26 |
import javafx.scene.control.TextField; |
27 |
|
28 |
/**
|
29 |
* Let's say hello to the world.
|
30 |
*
|
31 |
* Controller class for the "Hello world!" view. References the FXML layout and contains all control
|
32 |
* logic.
|
33 |
*
|
34 |
* @author munaro
|
35 |
*/
|
36 |
public class HelloWorldFXController extends CompositeFXControllerBase { |
37 |
|
38 |
/** {@link TextField} for inserting names. */
|
39 |
@FXML
|
40 |
private TextField nameTextField; |
41 |
|
42 |
/** {@link Button} to submit the inserted name. */
|
43 |
@FXML
|
44 |
private Button submitButton; |
45 |
|
46 |
/** {@link Label} to display the greeting. */
|
47 |
@FXML
|
48 |
private Label displayLabel; |
49 |
|
50 |
/** {@inheritDoc} */
|
51 |
@Override
|
52 |
public String getFXMLLocation() { |
53 |
return "HelloWorldLayout.fxml"; |
54 |
} |
55 |
|
56 |
/** {@inheritDoc} */
|
57 |
@Override
|
58 |
public void initialize(ICompositeFXController[] containments) { |
59 |
displayLabel.setText("...");
|
60 |
} |
61 |
|
62 |
/** Displays the greeting when the "Submit" button is pressed. */
|
63 |
public void onSubmit() { |
64 |
displayLabel.setText(format("Hello %s!", nameTextField.getText()));
|
65 |
} |
66 |
} |