This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jTextArea  RSS feed

 
warwick rose
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again

i have one more small problem in my GUI i have a text area which has to display my test orders now what is happing instead of the text showing up in the JtextArea its still printing to the console
so this order code (yes i did not use proper code standers) runs though my order class fine but its not loading the text in the JtextArea

order code



my jbutton code



i have 10 test case to load in the jTextArea

I'm learning more each time

thank you
Wazza
 
Campbell Ritchie
Marshal
Posts: 55735
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, why are those methods static?
You have a contradiction between what the method says it does and what it actually does. You say you are returning a String but you are actually displaying it on System.out. Then you are returning a one‑space String, which you will not see anywhere, even if you print it out. Return the String with the actual text, rather than printing it out.
 
Campbell Ritchie
Marshal
Posts: 55735
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way: that method will only set the text area to show the last test. You would have to catenate the Strings together if you want them all to appear. You may find it is so long that you need a scroll pane around the text area.
 
warwick rose
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

well i have to have it as static because thats what they asked for and what is to be printed out is as follows

Test Order 1
order number 1
Product Name Pencil
Product Price 0.6
Order Quantity 5
Total Price 3.00

this is what complied in the console and so on for the next 9 orders on net beens but i need it in the text area and the System.out.println() refers to the Order class

 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell has told you what to do:
Return the actual string from your testCaseX methods rather than printing it to the console and then either concatenate all the Strings before calling setText() or use the JTextArea's append() method to add each returned String to the existing text rather than repeatedly calling setText() which overwrites any existing text.
 
Campbell Ritchie
Marshal
Posts: 55735
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
warwick rose wrote: . . . i have to have it as static because thats what they asked for . . .
No more explanation than that? Have you been taught what static means?

And I had forgotten that text areas have an append method. Thank you for the reminder Tony.
 
warwick rose
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your help re read it today was tired last night worked it out

thanks so much
 
Campbell Ritchie
Marshal
Posts: 55735
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!