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 3 of 3

Thread: Simple Calculator

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Simple Calculator

    Hi there, I'm building a simple GUI calc with swing + netbeans.
    I'm a little puzzled on how to organise input and output given that the screen needs to default back to 0.0 instead of just a blank bar. I need it so when you enter text the 0.0 disappears, and control when it reappears/disappears.

    I've tried things like
    (This will be pressing the 0 button.)
     
    if(txtDisplay.getText() == "0.0"){
               reset();
               txtDisplay.setText("0")
    }else{
                txtDisplay.setText(txtDisplay.getText() + " 0");
    }
    Thanks.
    Last edited by Norm; February 25th, 2013 at 06:22 AM. Reason: added ending code tag


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,256
    My Mood
    Hungover
    Thanks
    142
    Thanked 618 Times in 529 Posts

    Default Re: Simple Calculator

    First off, don't use == with String. Do a search of these forums or on google for great explanations on what you should use instead.

    Secondly, you don't tell us what this code actually does. Does it work? Throw an error? Something else?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Spanky13 (February 25th, 2013)

  4. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Calculator

    thanks i have researched it and found suitable answer.

Similar Threads

  1. [SOLVED] Simple Salary Calculator Program
    By Blasfemmy in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 18th, 2012, 04:00 PM
  2. Simple Commission Calculator
    By mrivera8504 in forum What's Wrong With My Code?
    Replies: 22
    Last Post: August 27th, 2012, 06:35 PM
  3. [SOLVED] Simple calculator issue
    By ikocijan in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 20th, 2012, 02:43 AM
  4. Need help building a simple calculator
    By zigma in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 14th, 2011, 01:13 AM
  5. Simple Calculator
    By JKDSurfer in forum Loops & Control Statements
    Replies: 3
    Last Post: June 28th, 2011, 01:37 PM

Tags for this Thread