Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: WindowBuilder - beginner problem.

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    22
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default 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,

    int a = text_1;

    is seemingly no good here.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,384
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default 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
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    22
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: WindowBuilder - beginner problem.

    Quote Originally Posted by Norm View Post
    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?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,384
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: WindowBuilder - beginner problem.

    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?

    the string inside it?
    The TextField class has methods for accessing the String that is contains. See the API doc.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. help with swing in eclipse + windowbuilder
    By ganeshrnet in forum AWT / Java Swing
    Replies: 0
    Last Post: December 10th, 2012, 02:56 AM
  2. WindowBuilder - How do I open a seperate class window by a button?
    By tizen in forum Java Theory & Questions
    Replies: 1
    Last Post: July 29th, 2012, 05:11 PM
  3. WindowBuilder Pro
    By Kostas Pap. in forum AWT / Java Swing
    Replies: 1
    Last Post: July 27th, 2012, 09:58 AM
  4. Beginner problem with a do-while.
    By Eliijahh in forum Loops & Control Statements
    Replies: 3
    Last Post: November 21st, 2011, 12:28 PM
  5. Beginner Problem
    By jokibaer in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 15th, 2011, 06:34 PM