Solved

need help with getImage()

Posted on 1998-07-30
6
231 Views
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?
0
Comment
Question by:typhoid
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
aziz061097 earned 50 total points
Comment Utility

Do something like this

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

0
 

Author Comment

by:typhoid
Comment Utility
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?
0
 
LVL 2

Expert Comment

by:aziz061097
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:aziz061097
Comment Utility
I put the image file About.jpg in a sub directory "test".
0
 

Author Comment

by:typhoid
Comment Utility
i could figure it out, i just wasn't positive, and i like to be positive.  anyway, thanx for the advice, it might help
0
 

Expert Comment

by:tparvaiz
Comment Utility
Mr aziz have my reguards, i appreciate your help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now