• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Display Loop Results In TextArea Instead Of Command Window  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a little more tinkering I got it figured out, guess we can close this one.

Thanks.
 
Marshal
Posts: 59745
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Marshal
Posts: 59745
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know how to use printf, you will find String#format very easy to use.>
 
Campbell Ritchie
Marshal
Posts: 59745
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for tabs, try here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!