package javafxapp;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
// Main class representing the JavaFX application
public class JavaFXapp extends Application {
// Entry point of the JavaFX application
@Override
public void start(Stage primaryStage) {
// Label to display the result
Label result = new Label();
// TextFields for user input
TextField m1 = new TextField();
[Link]("Enter number 1");
TextField m2 = new TextField();
[Link]("Enter number 2");
// Button to trigger the calculation
Button calculate = new Button();
[Link]("Calculate");
[Link](new EventHandler<ActionEvent>() {
// Event handler for the button click
@Override
public void handle(ActionEvent event) {
try {
// Parse the input and calculate the sum
int num1 = [Link]([Link]());
int num2 = [Link]([Link]());
int sum = num1 + num2;
[Link]("The sum is: " + sum);
} catch (NumberFormatException e) {
// Handle invalid input (non-integer input)
[Link]("Invalid input! Please enter two valid
integers.");
}
}
});
// Layout for organizing the UI components
VBox root = new VBox();
[Link](new Insets(10));
[Link](5);
[Link]().addAll(m1, m2, calculate, result);
// Scene that holds the root layout
Scene scene = new Scene(root, 300, 250);
// Set up the primary stage (main window) of the application
[Link]("Add two numbers");
[Link](scene);
[Link]();
}
// Main method to launch the JavaFX application
public static void main(String[] args) {
launch(args);
}