Solved

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

Posted on 1998-09-02
4
195 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to Alipay 10 43
ejb message driven bean mdb creation steps 2 20
Java Eclipse Loop 3 20
learn programming 8 37
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 “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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

856 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