Saturday, 22 February 2014

JavaFX Create a button

Create a simple JavaFX application which displays a button.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;


public class TestApp extends Application {

 @Override
 public void start(Stage primaryStage) throws Exception {
  primaryStage.setWidth(600);
  primaryStage.setHeight(400);
  
  Button playButton = new Button("Button");
  Group group = new Group();
  group.getChildren().add(playButton);
  BorderPane root = new BorderPane();
  root.setCenter(group);
  Scene scene = new Scene(root);
  primaryStage.setScene(scene);
  
  primaryStage.show();
 }
 
 public static void main(String[] args) {
  launch(args);
 }

}

No comments:

Post a Comment