Originally Posted by steme
Easiest way that you can do in 1 chained line or a few lines is to first keep jtf.Message.getText() as that retrieves and represents the value as a String object. To get that into a primitive int, you should first use the int's wrapper class (Integer), which "converts" it from a String object to an Integer object. Next, the .parseInt() method basically parses the Integer object as a primitive int. The one problem with this is this conversion is vulnerable to the user entering inappropriate data, such as letters, symbols, nothing at all, decimals or really big integers. These can be addressed though by try-catch blocks or throwing exceptions.