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: Telling the user they left their input blank **GUI**

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Telling the user they left their input blank **GUI**

    Can anybody help me what I'm doing wrong here?

    Grot

    private void convertDtoEActionPerformed(java.awt.event.ActionEvent evt) {                                            
            double sol = (Double.parseDouble(usdInput.getText()) * 0.7715);
     
            if (usdInput.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "One of the required field is empty!", "Error", JOptionPane.ERROR_MESSAGE);
            }
            else{
                euroOutput.setText(usdInput.getText() +" USD = " + sol + " Euro");
                convertDtoE.setEnabled(false);  
     
            }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Telling the user they left their input blank **GUI**

    Why do you think there is something wrong? What happens when the program is executed?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Telling the user they left their input blank **GUI**

    The .showMessageDialog doesn't seem to appear, The code look correct yes?

    Grot

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Telling the user they left their input blank **GUI**

    Hard to tell. Best way to see if code is working is to compile and execute it.
    Print out the values of the variables that are being tested in the if statement to see why it is doing what it is doing.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Take user input
    By frabbi.cse in forum Java Theory & Questions
    Replies: 1
    Last Post: July 22nd, 2012, 12:48 PM
  2. Need help with user input/output for GUI.
    By Tctwins in forum AWT / Java Swing
    Replies: 6
    Last Post: February 20th, 2012, 04:13 PM
  3. Help, I have no idea what my console is telling me. :(
    By Zack22 in forum Java Theory & Questions
    Replies: 3
    Last Post: November 18th, 2011, 08:48 AM
  4. url input stream returning blank
    By yo99 in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: June 2nd, 2010, 08:14 PM
  5. User Input Loop
    By cfmonster in forum Loops & Control Statements
    Replies: 7
    Last Post: August 24th, 2009, 01:52 PM