59 lines
1.5 KiB
Java
59 lines
1.5 KiB
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMain.java to edit this template
|
|
*/
|
|
package javafxapplication1;
|
|
|
|
import javafx.application.Application;
|
|
import javafx.event.ActionEvent;
|
|
import javafx.event.EventHandler;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.layout.StackPane;
|
|
import javafx.stage.Stage;
|
|
|
|
/**
|
|
*
|
|
* @author caleb
|
|
*/
|
|
public class JavaFXApplication1 extends Application {
|
|
|
|
@Override
|
|
public void start(Stage primaryStage)
|
|
{
|
|
Button btn = new Button();
|
|
btn.setText("Say 'Hello World'");
|
|
Button btn2 = new Button();
|
|
btn2.setText("I'm a new button");
|
|
btn2.al
|
|
btn2.setLayoutY(250);
|
|
btn.setOnAction(new EventHandler<ActionEvent>() {
|
|
@Override
|
|
public void handle(ActionEvent event)
|
|
{
|
|
System.out.println("Hello World!");
|
|
}
|
|
|
|
});
|
|
|
|
StackPane root = new StackPane();
|
|
root.getChildren().add(btn);
|
|
root.getChildren().add(btn2);
|
|
|
|
Scene scene = new Scene(root, 500, 250);
|
|
|
|
primaryStage.setTitle("Hello World!");
|
|
primaryStage.setScene(scene);
|
|
primaryStage.show();
|
|
}
|
|
|
|
/**
|
|
* @param args the command line arguments
|
|
*/
|
|
public static void main(String[] args)
|
|
{
|
|
launch(args);
|
|
}
|
|
|
|
}
|