The javafx.geometry.Pos library does not include in javafx
Answered
I’m learning javafx, but for some reason I can’t see the class javafx.geometry.Pos and, accordingly, I can’t set it in any way, for example root.setAlignment(Pos.CENTER); It says that Pos is not an allowed character. And in the project file Pos.class is marked with an excellent icon (you can see it in the photo). What could be the problem? Inserted import javafx.geometry.Pos; It also writes an error.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.FlowPane; import javafx.stage.Stage; import javafx.geometry.*; // import javafx.geometry.Pos; not available public class JavaFXAlignment extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { Label label1 = new Label("Label1"); Label label2 = new Label("Label2"); FlowPane root = new FlowPane(10, 10, label1, label2); // root.setAlignment(Pos.CENTER); // doesn't work Pos.!? Scene scene = new Scene(root, 300, 150); primaryStage.setScene(scene); primaryStage.setTitle("FlowPane in JavaFX"); primaryStage.show(); } }
1 comment
Sort by
Date
Votes
Hi, is your JavaFX project based on Maven? I've created one project using IDEA's 2024.2.1, File | New | Project | JavaFx, which works well. Could you please provide a minimal sample project(maybe on GitHub or upload it to https://uploads.jetbrains.com/ and paste the upload id here.) so I can look into the issue without including your sensitive code? Thank you!
Please sign in to leave a comment.