Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package helloworld;
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.geometry.Insets;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextArea;
- import javafx.scene.layout.VBox;
- import javafx.stage.Stage;
- public class HelloWorld extends Application {
- private int helloCounter = 0;
- @Override
- public void start(Stage primaryStage) {
- Button btn = new Button();
- btn.setText("Say 'Hello World'");
- final TextArea textArea = new TextArea();
- btn.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- textArea.setText(textArea.getText()+"Hello World! ("+helloCounter+")\n");
- helloCounter++;
- }
- });
- VBox root = new VBox(10);
- root.setPadding(new Insets(10));
- root.getChildren().add(btn);
- root.getChildren().add(textArea);
- Scene scene = new Scene(root, 300, 250);
- primaryStage.setTitle("Hello World!");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement