I have an old thread from here, Redirect System.out.println() to a JTextArea/JTextPane?:
How to use the second code to output the Timer to JText instead of the console?
Dr. Richie Campbell has suggested some codes which he unfortunately did not test.
My question was not about codes, or only asking for codes.
My experiment is on a different area:
Isn't there modularity in Java, so that no good lines are touched, but simply the part that is needed to be changed are changed without affecting the rest codes?
Like I posted two codes.
The part which I don't want is the system.out.println() part. Can't only that part be replaced?
I wanted to test the modularity of Java, just by replacing a part which I don't want with something that works as intended.
That is called inheritance, I think, whereby you override some method and don't override the others. You have already shown an example in the form of the anonymous class you showed earlier.
Rajib Ban wrote:. . . Isn't there modularity in Java, so that no good lines are touched, but simply the part that is needed to be changed are changed without affecting the rest codes? . . .
I apologise for the error, Sir!
Campbell Riichie wrote:It's Campbell Ritchie, not Richie Campbell.
Thank you, Sir, for showing me my place. It would be nice if you henceforth could please ignore my posts, Sir!
Campbell Riichie wrote:I didn't think it was my place to test the code; that is your responsibility.
Rajib Ban wrote:Isn't there modularity in Java, so that no good lines are touched, but simply the part that is needed to be changed are changed without affecting the rest codes?
Not automatically, no. "Modularity" doesn't mean that arbitrary pieces of code can be automatically replaced by something else.
Having said that: You've already found an answer to your particular question, and Campbell gave you a start towards implementing that for your particular situation. You rejected that because it didn't work immediately, but you should remember we aren't here to do your work for you. We're here to guide you through the learning process. You can ask me not to reply to you in future, and if you do that I will not reply to you in future. But if you do that often enough there won't be anybody left here to talk to you. I'd advise you not to act in that way.
Since that post of mine, I've partly solved the issue, but a minor toothache remains. Unfortunately, I have already sought for suggestions from the Eclipse forum with my post, here. So I can no longer post the issue here, to avoid duplication of efforts on the behalf of the repliers.
However, you are at liberty to read the Eclipse forum post and advise me here, or desist from visiting the link or advising me. I presume that nothing stops you from your exercising your free will!
My regards for your understanding and a better reply, treating me as your equal.