954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error checking help required

Hi guys well my code is below I am trying to set up error checking so that CREATETABLE will only execute when String v and string d are false and when string t is true. I've started the code. Which it works when String v or String d are null so what else would I need to do or change to get it to work when string v,d are false.

Thanks for any help you can give:

String t = TABLENAME.getText();
            String v = colum1NAME.getText();
            String d = colum2NAME.getText();
            
          
        
        
        
        if (e.getSource() == CREATETABLE) {
        
        if (v.equals("") ^ d.equals("")) {
                showMessageDialog(this, "Only enter tablename name");
                return;
            }
TIM_M_91
Junior Poster in Training
58 posts since Feb 2012
Reputation Points: 18
Solved Threads: 0
 

true abd false are boolean values and are not a valid values for a String variable. What exactly do you mean when you refer to a String as true or false?

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 
true abd false are boolean values and are not a valid values for a String variable. What exactly do you mean when you refer to a String as true or false?

What I am trying to do is when my CREATETABLE button is pressed to only execute when v,d have no values and if they have values entered produce an error message. Hope that explains it better

TIM_M_91
Junior Poster in Training
58 posts since Feb 2012
Reputation Points: 18
Solved Threads: 0
 

You have the basic test for an empty String already (v.equals("")) so what you are missing is && for AND and ! for NOT.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 
You have the basic test for an empty String already (v.equals("")) so what you are missing is && for AND and ! for NOT.

Thanks got it working this is what I did:

if (v.equals("") ^ d.equals("") & d.equals("") || ! v.equals("")) {
                showMessageDialog(this, "Only enter tabelname");
                return;
            }
TIM_M_91
Junior Poster in Training
58 posts since Feb 2012
Reputation Points: 18
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: