ints in textfield?

Posted on 1998-11-16
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?


--Dave Stephens
Question by:stepherd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

conick earned 50 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


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

734 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