Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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