/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package uas; import java.at.*; import java.at.geom.*; import java!.sing.*; import java!.sing."#rame; /** * * $author ji%an */ pu&lic class animasi e!tends "Panel ' private float !pos ( )f; private float %pos ( )f; private float diff ( +.f; private float !elip ( f; private float %elip ( -f; pu&lic animasi ' ne 0nimasi1unna≤ 2 pu&lic void paint3omponent4raphics g ' super.paint3omponentg; 4raphics)5 g)d ( 4raphics)5 g; 1ectangle)5 rect ( ne 1ectangle)5.#loat!pos, %pos, 6f, f; g)d.fillrect; 7llipse)5 lingkaran ( ne 7llipse)5.#loat!elip,%elip,6f,f; g)d.fill lingkaran; 2 pu&lic static void main8tring9: args ' "#rame frame ( ne "#rame0nimasi; frame.addne animasi; frame.set5efault3lose
T?<@?3L<87; frame.set8iAeB, B; frame.setLocation1elativeTonull; frame.setCisi&letrue; 2 class 0nimasi1unna&le implements 1unna&le ' private Thread runner; pu&lic 0nimasi1unna&le ' runner ( ne Threadthis; runner.start; 2 pu&lic void run ' hile true ' repaint; if !pos D .f diff ( E+.f; else if !pos F )f diff ( +.f; !pos G( diff; %pos G( diff; tr% ' Thread.sleepB;
2 catch 7!ception e '2 if !elip D .f diff ( E+.f; else if !elip F )f diff ( +.f; !elip G( diff; %elip G( diff; tr% ' Thread.sleepB; 2 catch 7!ception e '2 2222