Solved

ints in textfield?

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

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where to store the queries for modification of table 4 61
diffSum example 4 36
MySQL  on Tomcat 8 43
How to convert String matching to regex in java 4 30
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now