Pages : 1
#1 Le 12/09/2019, à 11:12
- ilyes2293
JavaFx sur ubuntu 18.04
Bonjour à tous,
J'ai un peit soucis au niveau des package de GUI java (JavaFx).
Mon probléme que qd je veux execute le code suivant:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void init() {
System.out.println("Initialization (init())");
}
@Override
public void start(Stage mainStage) {
System.out.println("Running (start(Stage))");
// Title of the window
mainStage.setTitle("My First JavaFX App");
// Start by building the "Hello JavaFX" button
Button btnHello = new Button("Hello JavaFX");
// It can be resized, and we can add a background and a border (inherit from Region)
//btnHello.setPrefSize(120,80);
btnHello.setBorder(new Border(new BorderStroke(Color.DARKRED, BorderStrokeStyle.SOLID, null, new BorderWidths(5))));
btnHello.setPadding(new Insets(20,50,40,100));
// Define the main container (e.g. any layout-pane) and add the button
BorderPane root = new BorderPane();
root.setCenter(btnHello);
// Build the Scene by giving the root pane
Scene scene = new Scene(root, 250, 100);
// Finally, set the Scene in the Stage and show the window
mainStage.setScene(scene);
mainStage.show();
}
@Override
public void stop() {
System.out.println("Closing (stop())");
}
public static void main(String[] args) {
launch(args);
}
}
Le terminal me repond:
error: package javafx.application does not exist
import javafx.application.Application;
^
Main.java:2: error: package javafx.geometry does not exist
import javafx.geometry.Insets;
^
Main.java:3: error: package javafx.scene does not exist
import javafx.scene.Scene;
^
Main.java:4: error: package javafx.scene.control does not exist
import javafx.scene.control.Button;
^
Main.java:6: error: package javafx.scene.paint does not exist
import javafx.scene.paint.Color;
^
Main.java:7: error: package javafx.stage does not exist
import javafx.stage.Stage;
Quel est le probléme ?
Est ce que les package de JavaFx ne sont pas installé ? si non , cmt les installé ?
Merci d'avance de vos préciseuses information qui seront fournis
Ps:
qd je tappe
java -version
cela me donne:
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
Hors ligne
#2 Le 12/09/2019, à 11:26
- claudius01
Re : JavaFx sur ubuntu 18.04
Bonjour,
Si je cherche error: package javafx.geometry does not exist, je tombe sur cannot resolve symbol javafx.application in IntelliJ Idea IDE avec comme information :
As indicated here (Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?), JavaFX is no longer included in openjdk.
Sans doute qu'il faille installer le package à la mano comme indiqué dans le fil de discussion ;-)
Mais je me trompe peut-être
A suivre...
Hors ligne
Pages : 1