wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes can't rotate ellipse after certain period of time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can Watch "can New topic
Author

can't rotate ellipse after certain period of time

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
i have written code which will rotate ellipse after a certain period of time :

here's the code


Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3370
    
    9
What about your code?

TellTheDetails please.
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
ok i have made a custom component Block . The block starts a Timer which starts time . The Time class calls renderShape() method and that method calls repaint() .
At the paintComponent() i am changing the rotational angle by calling the rotate method . Now this is where the Rectangle should rotate .
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Never put any kind of business logic in a painting method override. You have absolutely no control over when and how often a painting method executes.


luck, db
There are no new questions, but there may be new answers.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3370
    
    9
It's because you rotate the graphical context by the same transformation, on every refresh. The graphical context is reset after a new call to paintComponent(). You need to use a variable to keep track of the total rotation so far. [edit] And as Darryl has said, you need to do this outside the paintComponent() method. Change the rotation in your Time class, for example.

Also:
- Why are your class fields not private?
- Why aren't you using layout managers?
- Why is onefourth actually three fourths?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't rotate ellipse after certain period of time
 
Similar Threads
Want confirmation that I am doing everything right
Magnifying only a part of the image
can't rotate ellipse
Having touble adding graphics to JPanel
Wanted: Java2D example of zooming and panning with scroll bars