1

I already have a class called validation that looks like this:

package Information;

public class Validation {

    public static boolean emptyString(String s) {
        if (s == null || s.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }
}

This is my Jframe class:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    if (Validation.emptyString(jTextField1.getText()) || Validation.emptyString(jTextField2.getText()))

    {
        JOptionPane.showMessageDialog(null, "Don't leave fields empty");
    } else {
        if (testaAdmin(jTextField1.getText(), jTextField2.getText())) {
            Basen basenFrame = new Basen();
            basenFrame.setVisible(true);
            this.dispose();
        } else {
            JOptionPane.showMessageDialog(null, "Wrong username or password");
        }

    }

}

The problem is that Validation in the Jframe class doesn't seem to get that it is supposed to communicate with the Validation class.

It just gives me this error message:

error: cannot find symbol Validation.emptyString(jTextField2.getText())) 

Why is this?

knowledge flow
  • 193
  • 4
  • 16
thunderboard
  • 19
  • 1
  • 2

2 Answers2

0

The problem is probably due to a missing import. If the Validation class is in a different package from the JFrame, it will need to be explicitly imported as per MrWiggles answer:

import Information.Validation;

I'd strongly suggest you download an an IDE, e.g. Eclipse or IntelliJ, as it will give you much more informative messages than the compiler and automated assistance to fix them.

Also, when you get a compiler error, you might use Google to find an explanation and save having to post a question on StackOverflow. You just need to omit your application-specific terms. Searching for: "error: cannot find symbol" finds a long StackOverflow post on the subject.

Community
  • 1
  • 1
ᴇʟᴇvᴀтᴇ
  • 12,285
  • 4
  • 43
  • 66
-1

You need to ensure you've imported your validation class. In the class you've got your JFrame, make sure you've got this line at the top:

import Information.Validation;
tddmonkey
  • 20,798
  • 10
  • 58
  • 67