When creating a new javafx project provided by maven, I get some errors in the console that cause the project to malfunction
I started writing the project and modifying a bit the one that is generated by default, but when calling some elements such as nodes and some events (in the case of one of the scene controllers), it generates errors to the console, the application opens, but does not it works as it should, I really don't know what to do, this project is the same as one that I had in eclipse ide, where it worked normally, but here when writing basically the same bop, the errors are generated, import the same project that I have in eclipse to vscode and in that case no error is generated and it works in the same way, I really don't know if it has to do with configuring the buildpath of the maven project in vscode, I don't know how to do it I'm new to vscode, I remember configuring the buildpath and some things in eclipse, but I have no idea how to do it here, if anyone has any suggestions or something I would appreciate it.
These are the errors that occur, and also the configuration of the project I think, it seems curious to me that the section for the javafx library does not appear
And these are the main archive:
package com.scenes;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
/**
* JavaFX App
*/
public class App extends Application {
private static Scene scene;
@Override//creamos aqui
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("menu"));
stage.setScene(scene);
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch();
}
}
And the controller scene:
package com.scenes;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.TranslateTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;//Deberemos importar un nodo para usarlo despues
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class MenuCont implements Initializable{
private Stage stage;
private Scene scene;
private Parent root;
@FXML
private Button Configuration;
@FXML
private StackPane StPane;
@FXML
private AnchorPane AnchorPane;
public void SwitchToConfig(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("menu.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public void switchToScene2(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("config.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
@FXML //ni puta idea de por que iba esta anotacion pero sin esto no lo reconoce xdd
private void loadSecond(ActionEvent event) throws IOException {//funciona? si pero no ejecuta la animacion por alguna razon, asi que eso ver que es y tambien probar con el codigo de movimiento del nerdo del video que ando viendo xd
//correcion, la mierda no carga nada del la otra escena.. wtf
Parent root = FXMLLoader.load(getClass().getResource("config.fxml"));
Scene scene = Configuration.getScene();
root.translateYProperty().set(scene.getHeight()); //aqui movemos el root (escena a cargar), en este caso la altura
StPane.getChildren().add(root);
TranslateTransition translate = new TranslateTransition();
translate.setNode(root);
translate.setDuration(Duration.millis(150));
translate.setToY(0);
translate.setOnFinished(event1 -> {
StPane.getChildren().remove(AnchorPane);//Esto se ejecuta al finalizar la animacion
});
TranslateTransition translat2 = new TranslateTransition();
translat2.setNode(AnchorPane);
translat2.setDuration(Duration.millis(200));
translat2.setToY(-500);
translate.playFromStart();
translat2.playFromStart();
}
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
// TODO Auto-generated method stub
}
}
And finally, here is the maven project pom file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.scenes</groupId>
<artifactId>periodic-table-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.scenes.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>