<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Ball.java</id>
		<title>Ball.java - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Ball.java"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Ball.java&amp;action=history"/>
		<updated>2026-05-06T15:41:31Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Ball.java&amp;diff=1432&amp;oldid=prev</id>
		<title>George2: Created page with &quot;&lt;source lang=&quot;java&quot;&gt;   import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import jav...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Ball.java&amp;diff=1432&amp;oldid=prev"/>
				<updated>2014-11-15T23:01:31Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import jav...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import javafx.animation.Animation;&lt;br /&gt;
import javafx.animation.KeyFrame;&lt;br /&gt;
import javafx.animation.Timeline;&lt;br /&gt;
import javafx.application.Application;&lt;br /&gt;
import javafx.event.ActionEvent;&lt;br /&gt;
import javafx.event.EventHandler;&lt;br /&gt;
import javafx.scene.Group;&lt;br /&gt;
import javafx.scene.Scene;&lt;br /&gt;
import javafx.scene.paint.Color;&lt;br /&gt;
import javafx.scene.shape.Circle;&lt;br /&gt;
import javafx.stage.Stage;&lt;br /&gt;
import javafx.util.Duration;&lt;br /&gt;
&lt;br /&gt;
public class Ball extends Application {&lt;br /&gt;
    static int dx = 1;&lt;br /&gt;
    static int dy = 1;&lt;br /&gt;
&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        Application.launch(args);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void start(final Stage primaryStage) {&lt;br /&gt;
        primaryStage.setTitle(&amp;quot;Animation&amp;quot;);&lt;br /&gt;
        Group root = new Group();&lt;br /&gt;
        Scene scene = new Scene(root, 400, 300, Color.WHITE);&lt;br /&gt;
&lt;br /&gt;
        primaryStage.setScene(scene);&lt;br /&gt;
        addBouncyBall(scene); &lt;br /&gt;
        primaryStage.show();&lt;br /&gt;
    }&lt;br /&gt;
    private void addBouncyBall(final Scene scene) {&lt;br /&gt;
        final Circle ball = new Circle(100, 100, 20);&lt;br /&gt;
&lt;br /&gt;
        final Group root = (Group) scene.getRoot();&lt;br /&gt;
        root.getChildren().add(ball);&lt;br /&gt;
&lt;br /&gt;
        Timeline tl = new Timeline();&lt;br /&gt;
        tl.setCycleCount(Animation.INDEFINITE);&lt;br /&gt;
        KeyFrame moveBall = new KeyFrame(Duration.seconds(.0200),&lt;br /&gt;
                new EventHandler&amp;lt;ActionEvent&amp;gt;() {&lt;br /&gt;
&lt;br /&gt;
                    public void handle(ActionEvent event) {&lt;br /&gt;
&lt;br /&gt;
                        double xMin = ball.getBoundsInParent().getMinX();&lt;br /&gt;
                        double yMin = ball.getBoundsInParent().getMinY();&lt;br /&gt;
                        double xMax = ball.getBoundsInParent().getMaxX();&lt;br /&gt;
                        double yMax = ball.getBoundsInParent().getMaxY();&lt;br /&gt;
&lt;br /&gt;
                        if (xMin &amp;lt; 0 || xMax &amp;gt; scene.getWidth()) {&lt;br /&gt;
                            dx = dx * -1;&lt;br /&gt;
                        }&lt;br /&gt;
                        if (yMin &amp;lt; 0 || yMax &amp;gt; scene.getHeight()) {&lt;br /&gt;
                            dy = dy * -1;&lt;br /&gt;
                        }&lt;br /&gt;
&lt;br /&gt;
                        ball.setTranslateX(ball.getTranslateX() + dx);&lt;br /&gt;
                        ball.setTranslateY(ball.getTranslateY() + dy);&lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
                });&lt;br /&gt;
&lt;br /&gt;
        tl.getKeyFrames().add(moveBall);&lt;br /&gt;
        tl.play();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>