I'm working on a simple object database app that displays various attributes of the entries in a class in a table and allows the user to add a new entry through a secondary input window.
Main:
public class Main extends Application {
Stage theStage;
Scene mainWindowController;
@Override
public void start(Stage primaryStage) throws Exception{
theStage = primaryStage;
Parent root = FXMLLoader.load(getClass().getResource("MainWindow.fxml"));
primaryStage.setTitle("Steam Database");
mainWindowController = new Scene(root, 800, 550);
primaryStage.setScene(mainWindowController);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
A controller for one of the secondary windows:
import static sample.MainWindowController.*;
public class CreateDeveloperWindowController {
/*
*/
@FXML
private TextField newDeveloperNameTextField;
@FXML
private TextField newDeveloperPassTextField;
private void handleCreateDeveloperButton() {
String proposedNewDevName = newDeveloperNameTextField.getText();
String proposedNewDevPass = newDeveloperPassTextField.getText();
if (proposedNewDevName.equals("") || proposedNewDevPass.equals("")) {
mainWindowController.textMessageDisplay.setText("Name and password must not be empty!");
} else {
allDevelopers.add(new Developer(proposedNewDevName, proposedNewDevPass));
}
}
/*
*/
}
The problem is in the controller, in the line
mainWindowController.textMessageDisplay.setText("Name and password must not be empty!");
I'm getting a "Cannot resolve symbol" error on it, but I can't discern why. One solution is to add "Main." in front of it and declare the variable static
, but that creates problems for other functionality that I want to add. So my questions are:
Why is this even showing up? The
mainWindowController
variable is declared within theMain
class, so it should be visible from anywhere in the application, so far as I'm aware.How do I solve this; how do I get that line to work?