Close Menu
Techs Slash

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Best Aircon Dealer in Singapore: How to Choose the Right One

    March 6, 2026

    How to Properly Screen a Water Tank Overflow

    March 5, 2026

    From Personal Experience: Why a Specialized Probate Administration Attorney Can Change Everything

    March 4, 2026
    Facebook X (Twitter) Instagram
    Techs Slash
    • Home
    • News
      • Tech
      • Crypto News
      • Cryptocurrency
    • Entertainment
      • Actors
      • ANGEL NUMBER
      • Baby Names
      • Beauty
      • beauty-fashion
      • facebook Bio
      • Fitness
      • Dubai Tour
    • Business
      • Business Names
    • Review
      • Software
      • Smartphones & Apps
    • CONTRIBUTION
    Facebook X (Twitter) Instagram
    Techs Slash
    Home»News»Java Applet Program to Show the Animation of a Bouncing Ball
    News

    Java Applet Program to Show the Animation of a Bouncing Ball

    Ranveer KumarBy Ranveer KumarSeptember 29, 2022No Comments2 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email

    Warning: Trying to access array offset on value of type bool in /home/cadesimu/techsslash.com/wp-content/themes/smart-mag/partials/single/featured.php on line 78
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Java Applet Program to Show the Animation of a Bouncing Ball

    // This java applet program will show 
    // the bouncing balls
    
    package Applet;
    
    import java.applet.*;
    import java.awt.*;
    
    public class BouncingBall extends Applet implements Runnable {
      // x,y coordinates and radius of the circle.
      int x = 150, y = 50, r = 20;
      int dx = 11, dy = 7;
    
      // create thread.
      Thread t;
      boolean stopFlag;
    
      // Function to start thread.
      public void start() {
        t = new Thread(this);
        stopFlag = false;
        t.start();
      }
    
      // Draw cicle from its present position.
      public void paint(Graphics g) {
        g.setColor(Color.red);
        g.fillOval(x - r, y - r, r * 2, r * 2);
      }
    
      // function to move the image.
      public void run() {
        while (true) {
          if (stopFlag)
            break;
          // Bounce if we've hit an edge.
          if ((x - r + dx < 0) || (x + r + dx > bounds().width)) dx = -dx;
          if ((y - r + dy < 0) || (y + r + dy > bounds().height)) dy = -dy;
          // Move the circle.
          x += dx;
          y += dy;
    
          try {
            Thread.sleep(100);
          } catch (Exception e) {
            System.out.println(e);
          };
          // print circle again n again.
          repaint();
        }
      }
    
      // function to stop printing.
      public void stop() {
        stopFlag = true;
        t = null;
      }
    }
    
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Ranveer Kumar
    • Website

    Related Posts

    What Happens When Algorithms Violate Consumer Rights?

    May 31, 2025

    Ludy Tatiana: A Pawn or the Queen?

    April 17, 2024

    Adult Wiseplay Lists Free and Updated

    March 28, 2024
    Leave A Reply Cancel Reply

    Top Posts

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    ABOUT TECHSSLASH

    Welcome to Techsslash! We're dedicated to providing you with the best of technology, finance, gaming, entertainment, lifestyle, health, and fitness news, all delivered with dependability.

    Our passion for tech and daily news drives us to create a booming online website where you can stay informed and entertained.

    Enjoy our content as much as we enjoy offering it to you

    Most Popular

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024
    CONTACT DETAILS

    Phone: +92-302-743-9438
    Email: contact@serpinsight.com

    Our Recommendation

    Here are some helpfull links for our user. hopefully you liked it.

    Techs Slash
    Facebook X (Twitter) Instagram Pinterest
    • Home
    • About us
    • contact us
    • Affiliate Disclosure
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • Write for us
    • Daman Game
    © 2026 Techsslash. All Rights Reserved

    Type above and press Enter to search. Press Esc to cancel.