You don't want to use a generic Maven Java project.

You should use either "FXML JavaFX Maven Archetype (Gluon)" or "Simple
JavaFX Maven Archetype (Gluon)"

It takes more than simply adding dependencies to get JavaFX to work, and
these two projects tweak the pom.xml file appropriately.

Regards,

Will Hartung


On Sat, Sep 4, 2021 at 10:03 PM Zulfi Khan <[email protected]>
wrote:

> Hi,
>
> I am able to run: FXMLJavaFXMaven Archetype and SimpleJavaFXMavenArchetype
> provided by Natebeans 12.4. Now I created the application using following
> steps:
>
>
> File-→NewProject-→ Java with Maven and Java
> Application-→ProjectName(JavaFx2) and then I right clicked on javafx2 from
> the project list-→New-→other-→JavaFX2 (Frome categories) and File
> Types(JavaFxMain Class)-→Next-→ClassName(Fx2FXMain) and
> Package(com.mycompany.javafx2)-→finish, I got following code with full of
> red balls (i.e. errors):
>
> import javafx.application.Application;//err package not exist
>
> import javafx.event.ActionEvent;//err package not exits and so in all
> import declaration
>
> import javafx.event.EventHandler;
>
> import javafx.scene.Scene;
>
> import javafx.scene.control.Button;
>
> import javafx.scene.layout.StackPane;
>
> import javafx.stage.Stage;
>
>
> /**
>
> *
>
> * @author zulfi
>
> */
>
> public class Fx2FXMain extends Application {
>
> @Override
>
> public void start(Stage primaryStage) {
>
> Button btn = new Button();
>
> btn.setText("Say 'Hello World'");
>
> btn.setOnAction(new EventHandler<ActionEvent>() {
>
> @Override
>
> public void handle(ActionEvent event) {
>
> System.out.println("Hello World!");
>
> }
>
> });
>
> StackPane root = new StackPane();
>
> root.getChildren().add(btn);
>
> Scene scene = new Scene(root, 300, 250);
>
> primaryStage.setTitle("Hello World!");
>
> primaryStage.setScene(scene);
>
> primaryStage.show();
>
> }
>
>
> /**
>
> * @param args the command line arguments
>
> */
>
> public static void main(String[] args) {
>
> launch(args);
>
> }
>
> }
>
>
> All import instructions are giving the error, package does not exits.
> Somebody please guide me.
>
>
> Zulfi.
>
>

Reply via email to