Please understand our predicament. You've posted code and have stated that it's not working correctly, but despite our requests for clarification, as of now, 10 hours later, no additional code or clarification has been forth-coming. And so we're stuck.
What we know is this:
- You have a method,
update(...)
that is supposed to be called when an Observable's state has changed.
- That this method is supposed to change the state of your GUI, that is, it is supposed to change the text shown in a JTextArea,
- But that it is not doing this.
Without additional information about all we can do is guess. Possible causes include:
- You're calling long-running code on the Swing event thread, freezing your GUI, so that even though the code that you show is running correctly, the Swing event thread is so busy that it's not able to paint the GUI and update the text area's text.
- ...or this update method is for some reason not being called due to an error in your (unshown) Observable's code.
- ...or you have more than one Observable, and the one being changed is not the one that is being observed
- ...or you hve more than one Observer object, and the one being notified is not the same one that holds the displayed JTextArea.
- Or the String
s
does not hold the information that you think it should hold. Again as per my comments, you are not using your update's arguments, and that risks not getting the correct information where you need it.
Again, please fix your question so that we can answer it without having to make wild, and likely incorrect guesses.