• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jTextArea

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
reply
    Bookmark Topic Watch Topic
  • New Topic