JavaFX 8 Quick Start on Eclipse for Ubuntu
Hi! The Tutorial shows you Step-by-Step How to Getting-Started with JavaFX 8 Hello-World Example on Latest Eclipse 2023-12 R IDE for Ubuntu 14.04 Trusty Tahr LTS GNU/Linux Desktop.
JavaFX is Java’s next-generation graphical user interface (GUI) toolkit that allows developers to rapidly build rich cross-platform applications.
JavaFX is good to build well-designed programming interfaces enabling developers to combine graphics, animation, and UI controls.
To Getting-Started with JavaFX 8 on Ubuntu an Oracle Java Development Kit 8 Installation is Needed on the System.
-
Open a Command Line Shell Session
Ctrl+Alt+t
(Press “Enter” to Execute Commands)In case first see: Terminal QuickStart Guide.
-
How to Install Eclipse for Java Developers on Ubuntu:
-
How to Install Eclipse Java FX Enviroment Plugin
-
Create a New Java Project.
-
Name it as HelloWorld.
Then Click on Finish.
-
Create a New Java Class.
Right-Click on src on the Package Explorer >> New >> Class
-
Name it as helloWorld and Check for main Method Creation.
-
Generate a Java FX Window with Hello-World Button.
Enter this Content on the Created Java Class:
/nimport javafx.application.Application;/nimport javafx.event.ActionEvent;/nimport javafx.event.EventHandler;/nimport javafx.scene.Group;/nimport javafx.scene.Scene;/nimport javafx.scene.control.Button;/nimport javafx.stage.Stage; public class helloWorld extends Application { public static void main(String[] args) { // TODO Auto-generated method stub Application.launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World"); Group root = new Group(); Scene scene = new Scene(root, 300, 150); Button btn = new Button(); btn.setLayoutX(100); btn.setLayoutY(60); btn.setText("Hello World"); btn.setOnAction(new EventHandler
() { public void handle(ActionEvent event) { System.out.println("Hello World"); } }); root.getChildren().add(btn); primaryStage.setScene(scene); primaryStage.show(); } } Ctrl+s to Save :)
-
Save & Run Java FX Hello-World.
-
Click on the “Hello World” Button
to Print “Hellow World” greeting on the Eclipse Console.