Solved

replace colored circle in applet with 2d or 3d image

Posted on 1998-09-02
4
193 Views
Last Modified: 2010-03-30
The source code is at the below url. It is a simple orbit
program which using colored circles for the planets moons and sun. I would like to replace them with planet and moon
and sun images in 2d or maybe 3d eventually.
http://ourworld.compuserve.com/homepages/bob_jenkins/orbit.htm
0
Comment
Question by:johnh619
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sailwind earned 50 total points
ID: 1223324
First of all, you've done a great job.
Second of all, yes you can replace them with images. Whether the image
is 2d or 3d will depend on the kind of gif/jpg that you put into it.

You can get the image by doing the following in your applet:

Image image = null;

try {
      image = getImage(new URL(getCodeBase() + logoname));
} catch (MalformedURLException e) {System.out.println("error, bad url");}

after you get the image, pass it to your paint() method, and paint it by using:

public void paint(Graphics g) {
     g.drawImage(image, x, y, width, height, this);
}

you can rotate the planets around the sun by updating the x and y coordinates
as the program runs.

Hope this helped!

0
 

Author Comment

by:johnh619
ID: 1223325
Could you check what I did? It did not compile but it looks
about right to me. I uploaded it to
http://users.aol.com/WARPMOTOR/moon.java
http://users.aol.com/WARPMOTOR/orbcode.jar also if you need this
to completely check the thing.
The moon.java is the only one that seems to need changes. I
did not use your exact suggestion because I had another
java file which is almost the same, in otherwords it is an
orbit program and it allows images but it is not as versatile
as the one I wish to modify.
I only have 4 points now, but I will be willing to let you have
more if you want to wait.
Thanks
0
 

Author Comment

by:johnh619
ID: 1223326
I forgot, you can see where I remarked out the lines and put in
mine right next to them, it should not be too hard to follow.
0
 
LVL 3

Expert Comment

by:sailwind
ID: 1223327
Okay, give me some time to look it over.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

920 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

14 Experts available now in Live!

Get 1:1 Help Now