• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

ints in textfield?

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?


--Dave Stephens
1 Solution
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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now