rotating a rectangle animation problem

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();
 
}
}
*****am expecting these code to provide animated rotating rectangle but its not working somebody can you please check it ************

Replies

You are reading an archived discussion.

Related Posts

British drugmaker GlaxoSmithKline had taken over Rockville-based Human Genome Sciences. The deal was signed in $3.6 billion after a months-long buyout dispute. This is one of the highest price paid...
NBC News has acquired msnbc.com and its digital network from Microsoft Corporation. With a shocking decision they had not taken any time and rebranded the site with immediate effect as...
Microsoft unveiled the new Microsoft Office aka The Microsoft Office 2013 few hours ago. Of all the features I'm most impressed by the 'comments' feature. I think this will go...
Tata Docomo has launched unlimited calling plan for Rs. 899 per month. This pre-paid plan is set to disrupt the Indian telecom markets yet again. Earlier the company had launched...
name- amit occupation- student i want to be- hydro engg hobbies- watching the mechanism of anything