File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Display Loop Results In TextArea Instead Of Command Window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Display Loop Results In TextArea Instead Of Command Window" Watch "Display Loop Results In TextArea Instead Of Command Window" New topic
Author

Display Loop Results In TextArea Instead Of Command Window

Brandon Buchanan
Greenhorn

Joined: Jan 07, 2012
Posts: 26
Hi everyone. This is my first post with coderanch.com and I am definitely a novice when it comes to programming. That being said, I hope you can help me with this issue that I am having. I have everything in my code working properly except for the fact that the payment amounts are being displayed in the command window and I need to display them in the text area. I have been scouring google and I just can't seem to find a way to move the results to the text area, so any help you could give would be much appreciated!

I realize that I am telling the results to go to the command window by using the System.out.printf but I just can't figure out how or what to change that to, in order to get it to put the output into the textArea of the GUI??

Thanks, you all are awesome, and I hope you can help!

Here is my code:
Brandon Buchanan
Greenhorn

Joined: Jan 07, 2012
Posts: 26
With a little more tinkering I got it figured out, guess we can close this one.

Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
Welcome to the Ranch

Brandon Buchanan wrote: . . . guess we can close this one.

Thanks.
No, you can’t. Several things can be improved. Your code formatting is inconsistent, not helped by your using tab characters; you ought to use spaces for indenting. Your lines are so long they are difficult to read. I have edited your post by splitting the longest lines.
Why have you got the three panels with a single Component in a Grid Layout? Why don’t you use one panel with a three-component Grid Layout?
I presume you used the setText() method of the text field to set its output. You may find the String#format method better than DecimalFormat. It is similar to printf, but creates a String object.
Brandon Buchanan
Greenhorn

Joined: Jan 07, 2012
Posts: 26
Campbell Ritchie wrote:Welcome to the Ranch

Brandon Buchanan wrote: . . . guess we can close this one.

Thanks.
No, you can’t. Several things can be improved. Your code formatting is inconsistent, not helped by your using tab characters; you ought to use spaces for indenting. Your lines are so long they are difficult to read. I have edited your post by splitting the longest lines.
Why have you got the three panels with a single Component in a Grid Layout? Why don’t you use one panel with a three-component Grid Layout?
I presume you used the setText() method of the text field to set its output. You may find the String#format method better than DecimalFormat. It is similar to printf, but creates a String object.


Haha! I knew someone would probably chime in with how bad my code is... sorry. I am new to java programming and I don't yet have it all figured out, obviously!

So, let's take your response and piece it out.
1. Code formatting inconsistent, and using tab characters --- I didn't know that it wasn't kosher to use tab characters? Is there a reason why this is bad? Also, thank you for editing the lines, I never knew how long is too long?
2.The 3 panels with the single component in a GridLayout --- I was just copying and pasting as I was going and I didn't realize that this could be set up differently? Do you have an example of how I can use one panel with a three-component GridLayout?
3. Are you talking about the setText() on line 165? I didn't know that this could be done differently either? Also, I am not familiar with the "String#format" and I have only ever used the decimalformat in my past assignments.

I am glad that you responded, I would love to learn how to become a better coder, and these kinds of things really do help! For now, my new assignment is working exactly as I need it to, but it's different than what was posted here because what's posted here was previously not working. However, if you wouldn't mind coaching me through some of the "issues" with my code, I will make the changes in my final version of the assignment and then repost for your review?

Thanks so much!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
If you know how to use printf, you will find String#format very easy to use.>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
As for tabs, try here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Loop Results In TextArea Instead Of Command Window