Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ints in textfield?

Posted on 1998-11-16
1
Medium Priority
?
242 Views
Last Modified: 2010-08-05
How does one go about producing a field that looks like a text field but that accepts integers as integers and not as strings?

For example:  If you have an applet with  the following:

      fieldtwo = new Panel();
      fieldtwo.add(label2 = new Label ("Value One: ",         Label.LEFT));
      fieldtwo.add(ipadd = new TextField(30));        
      add("South", fieldtwo);

And then later want to do this:

                  one = name.getText();

How can one make the variable "one" a int and not
a string?

Thanks!

--Dave Stephens
0
Comment
Question by:stepherd
1 Comment
 
LVL 7

Accepted Solution

by:
conick earned 100 total points
ID: 1227582
how about
one= Integer.parseInt(name.getText());

the textfield still doesnt accept an integer...
but as long as you can convert a string to an int easily it shouldnt matter

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importingā€¦
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question