Results 1 to 2 of 2
  1. #1
    Mira1000 is offline Member
    Join Date
    Nov 2011
    Posts
    7
    Rep Power
    0

    Default rotate() method??

    Hello i have a problem rotating an image.

    when i compile this code it gives me the "Cannot find symbol error" at tells it can't find the rotate() method.

    i have seen the rotate() method beeing used several times around the internet, so i don't understand this error.

    So is there anyone who can tell why??




    Java Code:
    import javax.swing.*;
    import java.awt.*;
    
    public class Xample extends JFrame{
    
    	public String txt="star.png";
    	public Image image;
    
    	Xample(){
    		ImageIcon imi = new ImageIcon(this.getClass().getResource(txt));
    		image = imi.getImage();
    
    		setSize(200,200);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setVisible(true);
    	}
    
    public Image getImage(){
    	return image;
    }
    
    public void paint(Graphics g){
    	super.paint(g);
    
    	Graphics g2d = (Graphics)g;
    	g2d.rotate(1);
    	g2d.drawImage(image,100,100,this);
    }
    
    public static void main(String[] s){
    	Xample app = new Xample();
    }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default Re: rotate() method??

    The rotate() method is in the Graphics2D class. You've stored your Graphics2D as its parent class, Graphics, so you don't have access to that method. Fix your cast.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. How to rotate an image
    By ChipChamp in forum New To Java
    Replies: 4
    Last Post: 06-20-2012, 07:22 PM
  2. Replies: 2
    Last Post: 04-01-2010, 04:16 PM
  3. Image rotate
    By Micromani in forum AWT / Swing
    Replies: 0
    Last Post: 03-17-2010, 01:33 PM
  4. My rotate 2d pos method isnt working correctly..
    By Addez in forum New To Java
    Replies: 5
    Last Post: 12-01-2009, 09:04 AM
  5. Rotate Image!
    By Moncleared in forum AWT / Swing
    Replies: 1
    Last Post: 02-11-2009, 05:22 PM

Posting Permissions

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