Please fix the code to allow it to run and compile sucessfullyFxHistoryController.java:19: error: class FXHistoryController is public, should be declared in a file named FXHistoryController.javapublic class FXHistoryController implements Initializable {FxNyResolutionController.java:72: error: cannot find symbol historyController.showWindow(); symbol: method showWindow() location: variable historyController of type FXHistoryControllerFxNyResolutionController.java:78: error: cannot find symbol historyController.showWindow(); symbol: method showWindow() location: variable historyController of type FXHistoryController // MainApp.java package NewYearsA6; import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application { @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("FXNyResolution.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); FxNyResolutionController controller = loader.getController(); NyrData nyrData = new NyrData(); controller.setModel(nyrData); primaryStage.setTitle("New Year's Resolutions"); primaryStage.setScene(scene); primaryStage.show(); loader = new FXMLLoader(getClass().getResource("FxHistory.fxml")); root = loader.load(); scene = new Scene(root); FXHistoryController controllerHistory = loader.getController(); controllerHistory.setModel(nyrData); controller.setHistoryController(controllerHistory); final Stage stageHistory = new Stage(); stageHistory.setTitle("History"); stageHistory.setScene(scene); // Uncomment if you want history window to be visible when the application starts // stageHistory.show(); } catch (IOException ex) { System.out.println(ex.getMessage()); System.out.println(ex.getCause()); ex.printStackTrace(); } } public static void main(String[] args) { launch(args); } }// NyrData.java package NewYearsA6; import java.util.ArrayList; import java.util.List; public class NyrData { public interface Listener { void onChange(NyrData nyrData); } private List<Listener> listeners = new ArrayList<>(); private ArrayList<String> unconfirmedResolutions = new ArrayList<>(); private ArrayList<String> confirmedResolutions = new ArrayList<>(); private ArrayList<String> history = new ArrayList<>(); public NyrData() { unconfirmedResolutions.add("start running"); unconfirmedResolutions.add("go to gym"); unconfirmedResolutions.add("8 hours sleep"); unconfirmedResolutions.add("eat healthy"); unconfirmedResolutions.add("be on time"); } public void addListener(Listener listener) { listeners.add(listener); } public void notifyObservers() { listeners.forEach(l -> l.onChange(this)); } public void confirm() { // Implement confirmation logic here notifyObservers(); } public void oops() { // Implement oops logic here notifyObservers(); } public void clearHistory() { history.clear(); notifyObservers(); } public ArrayList<String> getUnconfirmedResolutions() { return unconfirmedResolutions; } public ArrayList<String> getConfirmedResolutions() { return confirmedResolutions; } public ArrayList<String> getHistory() { return history; } }FxNyResolutionController.java needs to be included and rewriten FXHistoryController.java needs to be added to a file
Please fix the code to allow it to run and compile sucessfully
FxHistoryController.java:19: error: class FXHistoryController is public, should be declared in a file named FXHistoryController.java
public class FXHistoryController implements Initializable {
FxNyResolutionController.java:72: error: cannot find symbol
historyController.showWindow();
symbol: method showWindow()
location: variable historyController of type FXHistoryController
FxNyResolutionController.java:78: error: cannot find symbol
historyController.showWindow();
symbol: method showWindow()
location: variable historyController of type FXHistoryController
// MainApp.java
package NewYearsA6; import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application { @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("FXNyResolution.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); FxNyResolutionController controller = loader.getController(); NyrData nyrData = new NyrData(); controller.setModel(nyrData); primaryStage.setTitle("New Year's Resolutions"); primaryStage.setScene(scene); primaryStage.show(); loader = new FXMLLoader(getClass().getResource("FxHistory.fxml")); root = loader.load(); scene = new Scene(root); FXHistoryController controllerHistory = loader.getController(); controllerHistory.setModel(nyrData); controller.setHistoryController(controllerHistory); final Stage stageHistory = new Stage(); stageHistory.setTitle("History"); stageHistory.setScene(scene); // Uncomment if you want history window to be visible when the application starts // stageHistory.show(); } catch (IOException ex) { System.out.println(ex.getMessage()); System.out.println(ex.getCause()); ex.printStackTrace(); } } public static void main(String[] args) { launch(args); } }
// NyrData.java package NewYearsA6; import java.util.ArrayList; import java.util.List; public class NyrData { public interface Listener { void onChange(NyrData nyrData); } private List<Listener> listeners = new ArrayList<>(); private ArrayList<String> unconfirmedResolutions = new ArrayList<>(); private ArrayList<String> confirmedResolutions = new ArrayList<>(); private ArrayList<String> history = new ArrayList<>(); public NyrData() { unconfirmedResolutions.add("start running"); unconfirmedResolutions.add("go to gym"); unconfirmedResolutions.add("8 hours sleep"); unconfirmedResolutions.add("eat healthy"); unconfirmedResolutions.add("be on time"); } public void addListener(Listener listener) { listeners.add(listener); } public void notifyObservers() { listeners.forEach(l -> l.onChange(this)); } public void confirm() { // Implement confirmation logic here notifyObservers(); } public void oops() { // Implement oops logic here notifyObservers(); } public void clearHistory() { history.clear(); notifyObservers(); } public ArrayList<String> getUnconfirmedResolutions() { return unconfirmedResolutions; } public ArrayList<String> getConfirmedResolutions() { return confirmedResolutions; } public ArrayList<String> getHistory() { return history; } }
FxNyResolutionController.java needs to be included and rewriten
FXHistoryController.java needs to be added to a file

Step by step
Solved in 2 steps









