• Post Reply Bookmark Topic Watch Topic
  • New Topic

To output other than in Console?  RSS feed

 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Timer code from Oracle.

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?
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure. Let's try something:-Remember that some text components will take multiple lines and some won't. You may need a repaint() call on the text component too. You need to override every overloading. I don't know whether that is the correct code, but you can try it and see what happens.
 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Illustrious sheriffs,

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.
 
Dave Tolls
Ranch Hand
Posts: 2835
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell code shows you the sort of thing that will need to go in the commented bit of the code you copied from the other thread.

I;m not sure what other issues you might have with it?
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajib Ban wrote:. . . Dr. Richie Campbell has suggested some codes which he unfortunately did not test.  . . .
It's Campbell Ritchie, not Richie Campbell.

I didn't think it was my place to test the code; that is your responsibility.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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? . . .
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
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Riichie wrote:It's Campbell Ritchie, not Richie Campbell.
I apologise for the error, Sir!
Campbell Riichie wrote:I didn't think it was my place to test the code; that is your responsibility.
Thank you, Sir, for showing me my place. It would be nice if you henceforth could please ignore my posts, Sir!
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding your post, I am very able to understand the difference between empathy and alter. Yours was at my level, reaching out to me, with empathy. I will rather choose not to change my decision, based on my past experiences.

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.
 
Dave Tolls
Ranch Hand
Posts: 2835
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no problem with posting the same question in more than one forum, so long as you inform people you have done so.
That's the only thing people ask when crossposting.
 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will pause this thread and open a new one. Ther is lot of confusion here already!
Will come back to this thread later.
Regards
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!