Scenic View
This is a JavaFX application that interrogates the data of a running Java Application.
See also:
• Scenic View
Skeleton JavaFX Files
Sample application
This is the core of a JavaFX application. It assumes that an FXML file describes the content and
that the FXML controller is also this class. In order to use it we should:
• Change the class name
• Create an FXML file that names this class as its controller
• Change the FXMLLoader.load() call to point to the newly created FXML file
• Implement any logic in the initialize() function that is called when the controller is
started
• Ensure that any Java project that contains JavaFX also has the jfxrt.jar on the project's
build path
package com.kolban;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* @version 2014-05-05
*/
// Change class name
public class SampleApp extends Application{
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
// Change FXML file name and location
Parent root = FXMLLoader.load(getClass().getResource("fxml/Sample.fxml"));
Scene scene = new Scene(root, 600, 400);
stage.setScene(scene);
stage.show();
}
@FXML
private void initialize() {
} // End of initialized
} // End of class
// End of file
Sample Component
A component is a building block in the JavaFX architecture. It is common for us to want to create
Page 285
Comentários a estes Manuais