Animation in Java Swing – Kensoft PH https://kensoftph.com Power up your knowledge in programming Fri, 29 Oct 2021 08:54:40 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://kensoftph.com/wp-content/uploads/2021/07/cropped-Kensoftph-New-logo-32x32.png Animation in Java Swing – Kensoft PH https://kensoftph.com 32 32 Animation in Java Swing or Move components | 100% best for beginners https://kensoftph.com/animation-in-java-swing/ https://kensoftph.com/animation-in-java-swing/#comments Fri, 05 Feb 2021 13:51:00 +0000 https://kensoftph.com/how-to-move-components-in-java-programming-language-or-animation-in-java-programming-language/ Animation in Java Swing

Moving components in Java is pretty hard, but with this Application Programming Interface (API), you can simply move smoothly and easily with the components using “Kensoft Animation API“. 

Kensoft Animation

With this Jar file, you can actually move like jButton, jLabel, jPanel, etc.  Download the .jar file and implement it in your Java application.

 

Add the Kensoft Animation.jar to your libraries and import it into your code. Once you imported the package and the class. Create an object of Animation and call the public methods when you need it.

Kensoft animate = new Kensoft(); // Object of Animation

The public methods are parameterized with int start, int stop, int delay, int increment, and the component you want to animate.

  • int start – is the value of  X or Y coordinate

  • int stop – is the value of X or Y coordinate

  • int delay – is the value of milliseconds. Delay is a period of time by which something late or postponed

  • int increment – is the value (one or 1 is smoother) of the increment. It depends on you whether you run it smoothly.

  • and the component you want to animate. ( Button, Label, or whatsoever)

The syntax for importing the package

import KentHipos.Kensoft;

Animation in Java

Calling the public methods

animate.jLabelXRight(10, 500, 1, 1, jLabel);

Animation in Java

The animation or movement here is fast and smooth because of  1 millisecond of delay and 1 increment value.

Sample Code

private void jLabelMouseClicked(java.awt.event.MouseEvent evt){
    Kensoft animate = new Kensoft();
    animate.jLabelXRight(10, 500, 1, 1, jLabel);
}

Output

Animation in Java Swing

YouTube Video

]]>
https://kensoftph.com/animation-in-java-swing/feed/ 1 Java Tutorial: Animation in Java Swing nonadult