Results 1 to 9 of 9
 08172010, 09:58 AM #1Member
 Join Date
 Apr 2010
 Posts
 57
 Rep Power
 0
 08172010, 10:33 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
 08172010, 10:58 AM #3Member
 Join Date
 Apr 2010
 Posts
 57
 Rep Power
 0
OK, I understood explanation. Thank you very much for that.
I don't know how to code that. I have drawn a shape in paintComponent method like this:
Java Code:g.fillOval(50, 50, 20, 20);
Best regards,
Milica
 08172010, 12:55 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
Assume the circle's midpoint is the origin (0, 0); the midpoint of the ball makes a circular movement over a cirlce with radius Rr, so every point can be described as x= (Rr)*cos(phi), y= (Rr)*sin(phi) for any value of phi in [0, 2*PI).
You don't want to know where the midpoint of the ball is, you want to know the top left position of the bounding square; if the midpoint of the ball is at position (x, y) (see above) then the top left point of the bounding rectangle is at position (x(Rr), y(Rr))
The variable phi serves as a loop counter.
kind regards,
Jos
 08172010, 01:25 PM #5Member
 Join Date
 Apr 2010
 Posts
 57
 Rep Power
 0
Thank you very much for this explanation.
Should I use timer for this moving (to put that loop's code in it) or something similar?Last edited by mneskovic; 08172010 at 01:28 PM.
 08172010, 01:53 PM #6
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
 08172010, 02:08 PM #7Member
 Join Date
 Apr 2010
 Posts
 57
 Rep Power
 0
Can you explain me how to put timer in thread?
I have been making timers like this:
Java Code:timer1 = new Timer(500, new ActionListener() { public void actionPerformed(ActionEvent e) { x1++; PanelName.this.repaint(); }});
I would like to stop delays in timer, but if I put 0 instead of 500 it doesn't work well.
How to do that?
 08172010, 02:16 PM #8
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
 08172010, 03:05 PM #9Member
 Join Date
 Apr 2010
 Posts
 57
 Rep Power
 0
Similar Threads

how to change the shape of the JFrame to a oval shape
By kiki2009 in forum Java 2DReplies: 1Last Post: 04022010, 12:48 PM 
Hey Guys I need some help with rounding...
By blueduiker in forum New To JavaReplies: 8Last Post: 12082009, 09:58 AM 
Rounding
By Moncleared in forum New To JavaReplies: 2Last Post: 11172009, 09:16 AM 
Need help rounding. =/
By yo1mcool in forum New To JavaReplies: 1Last Post: 10072008, 05:02 AM 
Help with java Rounding
By silvia in forum New To JavaReplies: 1Last Post: 07202007, 07:25 AM
Bookmarks