java - Non-static method getText() can not be referenced from a static context -
i have written following code, continually 'non-static method gettext() can not referenced static context' error.
could me on right track here?
public class isbntext extends jtextfield { protected static string booknum; protected jtextfield booktext; public isbntext() { super(20); booktext = new jtextfield(); } public string getisbn() { string booknum = isbntext.gettext(); return booknum; } private string validateisbn(string booknum) }
this line:
string booknum = isbntext.gettext();
should be:
string booknum = gettext();
which implicitly:
string booknum = this.gettext();
the call isbntext.gettext()
trying call if it's static method - i.e. associated type rather specific instance of type. doesn't make sense, text is associated instance of type. 2 alternatives i've shown equivalent, finding text of isbntext
getisbn
has been called on.
Comments
Post a Comment