• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getDocumentBase() not working???

 
Vic Brown
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to build an applet. In the applet I add a control that I`ve written by having a seperate class that extends Canvas. Anybody know why this line will work in an Applet but not a class?
URL imgURL = null;
imgURL = new URL(getDocumentBase(), "bean.gif");
During compilation, I get a `cannot resolve symbol`
`symbol : method getDocumentBase ()
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because getDocumentBase is a method implemented in the Applet class. Java's more object-oriented than C++ - you ALWAYS have to have an object - or at least a class - associated with every method (notice I didn't use the words "subroutine" or "function"?). When you didn't explicity tie an object or class to the method. it tried "this.getDocumentBase()", then this.getClass().getDocumentBase() and in both cases found no method with that name in your newly-defined class.
[This message has been edited by Tim Holloway (edited August 12, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic