Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

746 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

11 Experts available now in Live!

Get 1:1 Help Now