• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
George Avilez
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 112 is where the problem is. Can anyone help me out?



 
Andrea Binello
Ranch Hand
Posts: 47
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!