WindowBuilder - beginner problem.
Please move the thread if there is a forum that is better suited.
I have a basic understanding of Java. However, GUI's are far out of my reportoire. I have a GUI with three textfields and a button. I want the user to enter two integers, one in each textfield, and press the button. The sum of the numbers will appear in the third textfield. I have no idea where to begin,
is seemingly no good here.
Re: WindowBuilder - beginner problem.
The text fields hold Strings. To do arithmetic with a String, convert it to a numeric data type by using a method in the Integer or Double class. Do the arithmetic and then convert the result to a String using a method in the String class and put that into the textfield.
See the API doc for each of the classes being used for the methods:
Java Platform SE 7
Re: WindowBuilder - beginner problem.
Quote:
Originally Posted by
Norm
The text fields hold Strings. To do arithmetic with a String, convert it to a numeric data type by using a method in the Integer or Double class. Do the arithmetic and then convert the result to a String using a method in the String class and put that into the textfield.
See the API doc for each of the classes being used for the methods:
Java Platform SE 7
I don't follow. How do I convert from Text to String, as Text is a new class? How do I make the program understand that it's not going to handle the textfield itself, but the string inside it?
Re: WindowBuilder - beginner problem.
Quote:
convert from Text to String
What is Text? Is that a new class that you are writing? Or is it from the Java SE classes/interfaces?
Quote:
the string inside it?
The TextField class has methods for accessing the String that is contains. See the API doc.