All Classes Namespaces Files Functions Variables
HelloWorldMain.java
Go to the documentation of this file.
1 package hello.button;
2 import javafx.application.Application;
3 import javafx.fxml.FXML;
4 import javafx.fxml.FXMLLoader;
5 import javafx.scene.Scene;
6 import javafx.scene.control.Label;
7 import javafx.scene.layout.Pane;
8 import javafx.stage.Stage;
9 
10 /**
11  * Yksinkertainen esimerkki JavaFX ohjelmasta joka hakee ulkoasun FXML-tiedostosta
12  * @author vesal
13  * @version 4.3.2016
14  */
15 public class HelloWorldMain extends Application {
16  @Override
17  public void start(Stage primaryStage) {
18  try {
19  Pane root = FXMLLoader.load(getClass().getResource("HelloWorldView.fxml"));
20  viesti = "Kiitti";
21  Scene scene = new Scene(root);
22  primaryStage.setScene(scene);
23  primaryStage.show();
24  } catch(Exception e) {
25  e.printStackTrace();
26  }
27  }
28 
29 
30  /** @param args ei käytössä */
31  public static void main(String[] args) {
32  launch(args);
33  }
34 
35  private String viesti = "Well Done";
36 
37  @FXML private Label label;
38 
39  @FXML private void handlePressed() {
40  label.setText(viesti);
41  }
42 
43 }