Java'da animasyon yapmak isteyen arkadaşlara yardımcı olması umidiyle boyle bir ders hazırlamak istedim.

Java ile calışmak isteyen arkadaşlara Merhaba...

Aşağıda calıştıracağınız java kodumuzla GKA(grafiksel kullanıcı arayuzu) cizip, fareyle birlikte, dikdortgen ve kare cizebiliyoruz, her saniyede.

Aynı zamanda renk değiştiren kodumuzla birlikte, şekillerimzin renkleri de değişmektedir.

Kolay gelsin */

PHP:
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JFrame; import javax.swing.JPanel; /*In this section; I defined first class and adds methods using JPANEL with extends and ı defined X and y are positions but * they are integer also ı wrote color functions. */ public class a3 extends JPanel /*With this function ; I draw circle and square on frame. Therefore; ı defined my shapes. They are; circle and rectangle. * and then ı wrote positions and ı gave an integer value for my shapes.For example; for rectangle, ı used * g.fillRect(posSX,posSy,50,250) etc. and tehn, ı defined their colors'.The end, ı defined circle's values. * For example; positions and coordinates */ public void paintComponent(Graphics g) /*İn this function, ı defined new Jpanel and BorderLayout and ı set their locations as a CENTER. also; * ı said that Frame's heading as an "ASS3" and ı set these knowledges in canvas.This canvas has size 500,500 * and ı clicked with mouse my shapes moving on canvas.Also; their colors changing each click. * Therefore; ı finished my worksheet in this week*/ public static void main(String[]args) } /* mouse events nodify when the uses the mouse to interact with a component. Mouse events occur when the cursor * enters or exits a component's onscreen area and when the user presses or releases one of the mouse buttons. This function runs on mouse buttons.*/ /*Mouse click: This function Called just after the user clicks the listened-to component*/ class ClickMouse implements MouseListener public void mouseClicked(MouseEvent e) /*Mouse Entered: This function Called just after the cursor enters the bounds of the listened-to component.*/ public void mouseEntered(MouseEvent e) /* Mouse exited: This function Called just after the cursor exits the bounds of the listened-to component.*/ public void mouseExited(MouseEvent e) /*Mouse pressed: This function Called just after the user presses a mouse button while the cursor is over the * listened-to component. (non-Javadoc)*/ public void mousePressed(MouseEvent e) /*Mouse released: This function Called just after the user releases a mouse button after a mouse press over * the listened-to component. Also; this function sets new position circle and rectangle both of them.*/ /*Also;it changing colors my shapes every click in new position.*/ public void mouseReleased(MouseEvent e) else if(e.getButton() == 3) } } /*Referances:java.sun.com,java.tutorial.com*/