Results 1 to 3 of 3
  1. #1
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default Rotating rectangle animation proble

    package rotatinganimation;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import javax.swing.*;
    import java.awt.Graphics2D;
    import java.awt.geom.*;

    public class Demo
    {
    Thread t1;
    int degree=8;
    public Demo()
    {
    JFrame frame=new JFrame("Tara Animation");
    frame.setSize(500,500);
    frame.add(new Rotate(),BorderLayout.CENTER);
    frame.setVisible(true);
    }

    class Rotate extends JPanel implements Runnable
    {
    public void start()
    {
    if(t1==null)
    {
    t1=new Thread(this);
    t1.start();
    }
    }
    public void run()
    {
    for(int i=0;i<16;i++)
    {
    repaint();
    try{
    Thread.sleep(10);
    }
    catch(Exception ex){}
    }
    }
    public void paint(Graphics g)
    {
    Graphics2D graph2=(Graphics2D)g;
    graph2.setColor(Color.red);

    graph2.translate(200,200);
    graph2.rotate(Math.PI/Math.toRadians(degree));

    Rectangle2D.Double rect=new Rectangle2D.Double(50,80,50,50);
    graph2.fill(rect);

    }

    }

    public static void main(String[] args)
    {
    Demo d=new Demo();

    }
    }

    **************guys what is the problem in my code what am trying to do is make a animation that rotates a rectangle ******

  2. #2
    doWhile is online now Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Rotating rectangle animation proble

    guys what is the problem in my code
    You tell us...does it compile? Are there exceptions? Does it misbehave? And please wrap your code in the code tags

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,413
    Rep Power
    20

    Default Re: Rotating rectangle animation proble

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

Similar Threads

  1. rotating a rectangle
    By janvos2506 in forum Java 2D
    Replies: 0
    Last Post: 07-15-2012, 04:55 PM
  2. Rotating Rectangle about its Centre
    By Lance in forum Java 2D
    Replies: 6
    Last Post: 02-28-2011, 11:28 PM
  3. Proble with connect
    By sabra in forum JDBC
    Replies: 10
    Last Post: 06-13-2010, 10:28 PM
  4. Replies: 1
    Last Post: 05-11-2009, 01:13 PM
  5. Proble displaying images dynamically in jsp
    By javaxprogrammer in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-09-2009, 08:13 AM

Posting Permissions

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