Results 1 to 3 of 3
- 07-17-2012, 03:04 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 14
- Rep Power
- 0
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 ******
- 07-17-2012, 03:21 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,608
- Rep Power
- 5
Re: Rotating rectangle animation proble
You tell us...does it compile? Are there exceptions? Does it misbehave? And please wrap your code in the code tagsguys what is the problem in my code
- 07-18-2012, 07:29 AM #3
Re: Rotating rectangle animation proble
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
rotating a rectangle
By janvos2506 in forum Java 2DReplies: 0Last Post: 07-15-2012, 04:55 PM -
Rotating Rectangle about its Centre
By Lance in forum Java 2DReplies: 6Last Post: 02-28-2011, 11:28 PM -
Proble with connect
By sabra in forum JDBCReplies: 10Last Post: 06-13-2010, 10:28 PM -
Proble with poi 3.1 while using CreateDrawingPatrich() method to add images into exc
By chaitudnvr@gmail.com in forum Advanced JavaReplies: 1Last Post: 05-11-2009, 01:13 PM -
Proble displaying images dynamically in jsp
By javaxprogrammer in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-09-2009, 08:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks