• 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

Error: 'Void' type not allowed here when trying to print out on JOption pane dialog box

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 112 is where the problem is. Can anyone help me out?



 
Ranch Hand
Posts: 62
5
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

George Avilez wrote:Line 112 is where the problem is. Can anyone help me out?


setText of JTextArea is a "setter" method, it has a void return type and obviously you can't use a void in an expression.
You have repeated the latinText.setText(translate(text)) just done before. Simply use latinText.getText() in the showMessageDialog invocation.

P.S. another (better) way is to assign the return value of translate to a variable, and than use this variable for latinText.setText and for the message of showMessageDialog.
 
George Avilez
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh ok I see. THere is no longer any run time errors but now the new text will not show my converted text. All it show's is ~Your sentence in pig latin is: (just a blank space)~
112-115 is the new look. Oh and btw the previous code was an older attempt. This one is slightly new with like 5 changes including the dialog box
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic