Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


need help with getImage()

Posted on 1998-07-30
Medium Priority
Last Modified: 2011-09-20
with the getImage() method, it needs a URL and a string name for the agruements.  what do i put for the URL if it is a local file, but not in the same directory as the applet itself.  therefore i can't use the "getDocumentBase()" or "getCodeBase()".  so what's the answer?
Question by:typhoid
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Accepted Solution

aziz061097 earned 100 total points
ID: 1229291

Do something like this

Image img = getToolkit().getImage("test\\About.jpg");
g.drawImage(img, 0, 0, 615, 430, this);


Author Comment

ID: 1229292
this might work, i kept getting a nullpointer exception which doesn't make sense to me, because there was nothing mispelled, and all the files were where i specified them to be.  i'm not sure what the "test" in your answer is, is that the path?

Expert Comment

ID: 1229293
Yes that is quite obvious . You have to escape the path ... I did not know you could not figure it out or I would give more explanation.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 1229294
I put the image file About.jpg in a sub directory "test".

Author Comment

ID: 1229295
i could figure it out, i just wasn't positive, and i like to be positive.  anyway, thanx for the advice, it might help

Expert Comment

ID: 1229296
Mr aziz have my reguards, i appreciate your help

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question