Created
September 22, 2015 01:13
-
-
Save smamran/abc1f2b7dddaece11b9c to your computer and use it in GitHub Desktop.
Java FX Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Always ensure Java Class Name is same as File Name in JavaFX. Otherwise give error in running | |
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; | |
public class Fxservidor extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override public void start(Stage primaryStage) { | |
primaryStage.setTitle("Hello World!"); | |
Button btn = new Button(); | |
btn.setText("Say 'Hello World'"); | |
btn.setOnAction(new EventHandler<ActionEvent>() { | |
@Override | |
public void handle(ActionEvent event) { | |
System.out.println("Hello"); | |
} | |
}); | |
StackPane root = new StackPane(); | |
root.getChildren().add(btn); | |
primaryStage.setScene(new Scene(root, 300, 250)); | |
primaryStage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment