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;
            }

Recommended Answers

All 4 Replies

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?

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

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

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;
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.