Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Seattle, WA
    Rep Power

    Default Rotating image with an Applet

    I'm trying to rotate an image with Applet, but I'm having some problems.

    Java Code:
    package Cell;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    public class Shiznit_2 extends Applet implements Runnable {
    	private Image ship;
    	int width = 300; 
    	int height = 300; 
    	int x = width/2; 
    	int y = height/2; 
    	int dx; 
    	int dy;
    	double angle= 0.0; 
    	AffineTransform turn;
    	BufferedImage bi;
    	Graphics2D bs;
    	Thread t;
    	public void start(){
            Thread gameThread = new Thread(this);
    	public void init() {
    		setSize(300, 300);
    		ship = getImage(getCodeBase(),"Cell/mito_0.gif");
    		turn = new AffineTransform();
    		 bi = (BufferedImage)createImage(WIDTH, HEIGHT);
    	        bs = bi.createGraphics();
    	public void run(){
    			turn.translate(x, y);
    			turn.rotate(Math.toRadians(angle), (50), (50) );
    	public void paint(Graphics g) {
    	public void update(Graphics g)
    		Graphics2D g2 = (Graphics2D)g;
            bs.clearRect(0, 0, WIDTH, HEIGHT);
            bs.drawImage(ship, turn, this);
            g2.drawImage(bi, 0, 0, this);

    Its supposed to spin the image using AffineTransform, but when I run it I just get a blank white screen.

    Some help or tutorials links would be nice!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Rotating image with an Applet

    Moved from New to Java

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Help with Image Rotating?
    By Leospaceman in forum Java 2D
    Replies: 2
    Last Post: 05-31-2011, 03:48 PM
  2. Problem in rotating an image
    By newtoapplets in forum Java Applets
    Replies: 0
    Last Post: 02-28-2011, 07:12 AM
  3. Rotating Buffered Image distorts image
    By VortexSpin in forum Java 2D
    Replies: 1
    Last Post: 02-13-2011, 06:54 AM
  4. Rotating an image
    By lackofcolor in forum Java 2D
    Replies: 3
    Last Post: 02-28-2009, 12:54 AM
  5. Rotating Image?
    By sciguy77 in forum Java Applets
    Replies: 9
    Last Post: 02-17-2009, 02:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts