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

Thread: Check if 'int' is empty

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Check if 'int' is empty

    Hi, I'm new to Java programing started learning it today. And have a bit of a problem.

    Then clicking button program converting Celsius to Fahrenheit and vice versa.
    I need to check 'CelsijusTextField' if it's not empty then program converting Celsius to Fahrenheit and
    if 'FarenheitasTextField' is not empty program converts Fahrenheit to Celsius.

            int Celsijus = (int)((Double.parseDouble(CelsijusTextField.getText())));
            int Farenheitas = (int)((Double.parseDouble(FarenheitasTextField.getText())));
            if (Celsijus != 0) {
                FarenheitasTextField.setText(Celsijus * 1.8 + 32 + "");
            } else if (Farenheitas != 0) {
                CelsijusTextField.setText((Farenheitas - 32 / 1.8) + "");
            }


  2. #2
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Check if 'int' is empty

    Hello TrYk!
    I need to check 'CelsijusTextField' if it's not empty then program converting Celsius to Fahrenheit and
    if 'FarenheitasTextField' is not empty program converts Fahrenheit to Celsius.
    A way to do this is with the isEmpty() method of the String class.
    String (Java Platform SE 7 )

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

    TrYk (March 10th, 2012)

Similar Threads

  1. how to check is DOUBLE JTEXTFIELD is empty?
    By myexternall11 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 22nd, 2012, 10:56 AM
  2. extended JPanel is empty
    By pottsiex5 in forum AWT / Java Swing
    Replies: 4
    Last Post: November 26th, 2011, 03:59 PM
  3. How to check for empty mysql table
    By A4Andy in forum Java Theory & Questions
    Replies: 1
    Last Post: August 26th, 2011, 11:43 PM
  4. Assigning an 'int' from a JTextField to a variable...
    By RiskyShenanigan in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 26th, 2011, 04:00 PM
  5. [SOLVED] Supressing empty lines and does not do until the end! Why ?
    By lumpy in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 18th, 2010, 07:38 AM