This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Scala and the fly likes getting string from textarea in scala Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Scala
Bookmark "getting string from textarea in scala" Watch "getting string from textarea in scala" New topic
Author

getting string from textarea in scala

phillip nash
Greenhorn

Joined: Feb 08, 2011
Posts: 21
Hello all!

I'm starting out learning how to use scala, but I'm finding the transition very tricky.

I'm writing a simple application where I enter text in a TextField and when I click "Show" it shows the text within the TextField
within the console.

In java all I need to do was to use ".getText()" to the the text from a JTextField.

How can I do this in scala? Or is it even possible?

Thanks
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Can you provide the code you are trying?


Mohamed Sanaulla | My Blog
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

If it's still a JTextField, then you can do exactly the same in Scala as you did in Java - just call .getText() on it to get the text.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

If you are using Scala swing's 'TextField' http://www.scala-lang.org/api/current/scala/swing/TextField.html, you can use 'text' method on the TextField to get the text.


- Marimuthu Madasamy
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: getting string from textarea in scala
 
Similar Threads
How to use hibernate in scala
cant figure this out
String to integer??
Scale or Clojure
questions about Process and Runtime()