eHow launches Android app: Get the best of eHow on the go.

How To

How to Use Graphics in a Java Applet

Contributor
By Thomas Walton
eHow Contributing Writer
(2 Ratings)

Learn to use graphics in a Java applet in a few simple steps. This article will help you learn where to find resources for new code. You will be able to draw just about any shape in any object, and import images and photos to your Java applet. Read on to learn how to use graphics in a Java applet.

Difficulty: Moderately Easy
Instructions

Things You'll Need:

  • Computer
  • Internet
  1. Step 1

    Locate your paint method. Set a parameter for a graphics class.

  2. Step 2

    In your code window, type: public void paint (Graphics g).

  3. Step 3

    In the graphics class you will set up your draw line method. To do this you must set the proper coordinates in sequence. This is easy. You name the angles you want to draw your line on, across and to. The following is an example code: g.drawLine (5, 32, 33, 50); Your code would draw a line from 5 to 32, then from 32 to 33, and arrive at 50.

  4. Step 4

    To import and draw images in to an object, you have to call the method. Type at the top of your code: import java.awt.Image.

Tips & Warnings
  • Read other resources for how to create codes for all kinds of shapes/ graphics in a Java applet. There are some good resources at this link.
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Demand Media
eHow_eHow Technology and Electronics