I'm building a lobby that should display messages from players.
Here is my lobby controller:
public class LobbyController{
@FXML public JFXTextArea chatArea;
@FXML public JFXTextField chatField;
public void displayChatMessage(String message){
chatArea.appendText(message);
}
@FXML
public void onEnter(){
Main.client.sendChatMessage(chatField.getText());
}
}
I'm accessing this controller from another class like this:
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("/views/lobby.fxml"));
fxmlLoader.load();
LobbyController controller = fxmlLoader.getController();
if(!gameStarted){
controller.displayChatMessage(((Packets.ChatMessage) o).message);
}
My controller is definitely receiving the message as if I put a print line in displayChatMessage()
, it prints the message correctly.
My problem is that appendText()
does not seem to be changing the text at all.