Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-09-02
4
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sailwind earned 100 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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