The class was not seeing some imports from the same package, and some getters and setters for User.java were not written, so I wrote those and fixed the imports FIX:: fixed packages Everything now isn't in several subpackages in the Client, Common and Server package anymore, but straight in their respectable packages. Also fixed the package names BUG FIX: fixed Client Application class not being able to see GetBean method Don't really know how it got fixed, but resolving the import issues also fixed this bug. EDIT::changed main class in build.gradle file to Client.Application --------------- I now only get a bug where the fxmlloader can't see the fxml files, and thus I can't start the application. I get the error message "location not set" although I used fxmlloader.setLocation.
67 lines
2.2 KiB
Java
67 lines
2.2 KiB
Java
package Client;
|
|
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.scene.Parent;
|
|
import javafx.scene.Scene;
|
|
import javafx.stage.Stage;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
import static org.springframework.boot.SpringApplication.run;
|
|
|
|
@SpringBootApplication
|
|
public class Application extends javafx.application.Application {
|
|
private ConfigurableApplicationContext springContext;
|
|
private Parent rootNode;
|
|
private FXMLLoader fxmlLoader;
|
|
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
|
|
|
public static void main(String[] args) {
|
|
launch(args);
|
|
}
|
|
|
|
// @Bean
|
|
// public RestTemplate restTemplate(RestTemplateBuilder builder) {
|
|
// return builder.build();
|
|
// }
|
|
|
|
@Override
|
|
public void init() throws Exception {
|
|
springContext = run(Application.class);
|
|
fxmlLoader = new FXMLLoader();
|
|
fxmlLoader.setControllerFactory(springContext::getBean);
|
|
}
|
|
|
|
@Override
|
|
public void start(Stage primaryStage) throws Exception{
|
|
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("main/Client/fxml/sample.fxml"));
|
|
// fxmlLoader.setLocation(Client.Application.class.getResource("resources/fxml/sample.fxml"));
|
|
Parent rootNode = fxmlLoader.load();
|
|
// Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("sample.fxml"));
|
|
// Image image = new Image("pinkleaf.png");
|
|
|
|
// rootNode = FXMLLoader.load(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
|
|
|
primaryStage.setTitle("GoGreen");
|
|
Scene scene = new Scene(rootNode);
|
|
primaryStage.setScene(scene);
|
|
primaryStage.show();
|
|
}
|
|
|
|
// @Override
|
|
// public void stop() {
|
|
// springContext.stop();
|
|
// }
|
|
|
|
// @Bean
|
|
// public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
|
|
// return args -> {
|
|
// User user = restTemplate.getForObject(
|
|
// "http://localhost:8080/user", User.class);
|
|
// log.info(user.toString());
|
|
//
|
|
// };
|
|
// }
|
|
} |