java - cannot find symbol error while using jframe -
this question has answer here:
i have class called validation looks this:
package information; public class validation { public static boolean emptystring(string s) { if (s == null || s.isempty()) { return true; } else { return false; } } }
this 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 validation in jframe class doesn't seem supposed communicate validation class.
it gives me error message:
error: cannot find symbol validation.emptystring(jtextfield2.gettext()))
why this?
the problem due missing import. if validation
class in different package jframe
, need explicitly imported per mrwiggles answer:
import information.validation;
i'd suggest download an ide, e.g. eclipse or intellij, give more informative messages compiler , automated assistance fix them.
also, when compiler error, might use google find explanation , save having post question on stackoverflow. need omit application-specific terms. searching for: "error: cannot find symbol"
finds long stackoverflow post on subject.
Comments
Post a Comment