• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getDocumentBase() not working???

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ()
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic