/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * @author cementovoz */ public class JavaFXApplication1 extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.getStyleClass().add("class1"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); VBox root = new VBox(20); root.getChildren().addAll(btn, new Button("Button 1"), new Label("Label 1")); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().add(getClass().getResource("/styles.css").toExternalForm()); primaryStage.setTitle("Hello World!" + VersionInfo.getRuntimeVersion()); primaryStage.setScene(scene); primaryStage.show(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }