0

Please help me to make this applet move. I want to make this 2 arms to move swaying. This code only shows his arms because I am not allowed to post here all the codes. Help me please! Thank you so much everyone! Here is my code:

import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.geom.*;

public class Pucca extends Applet {

public Pucca(){
setSize(700, 700); }

//paint method
public void paint(Graphics g){



    g.setColor(Color.BLACK);
    g.drawArc(432, 350, 50, 50, 0, 180); //left arc line arm

    g.setColor(Color.BLACK);
    g.drawArc(911, 350, 50, 50, 0, 180); //right arc line arm

    g.drawLine(482, 375, 432, 375); // left down arm

    g.drawLine(962, 375, 912, 375); //right down arm

    g.setColor(yellow);
    g.fillRect(450, 375, 20, 180); //left yellow arm


    g.setColor(Color.BLACK);
    g.drawRect(450, 375, 20, 180); //left black arm line

    g.setColor(yellow);
    g.fillRect(928, 375, 20, 180); // right yellow arm

    g.setColor(Color.BLACK);
    g.drawRect(928, 375, 20, 180); //right black arm line


     g.setColor(yellow);
    g.fillOval(435, 530, 50, 50); //left cirle yellow oval

    g.setColor(Color.BLACK);
    g.drawOval(435, 530, 50, 50); //left circle hand line


    g.setColor(yellow);
    g.fillOval(915, 530, 50, 50); //right  circle yellow oval

    g.setColor(Color.BLACK);
    g.drawOval(915, 530, 50, 50); //right circle hand line

}
}
  • Your paint method uses only fixed values, so create somewhere a thread that regularly changes some values and then calls `repaint` to ask for `paint`to be called by the UI thread. – Jean-Baptiste Yunès Apr 02 '16 at 15:39
  • After that, it will move afterwards? – Cherry Lugtu Apr 02 '16 at 15:49
  • *"This code only shows his arms because I am not allowed to post here all the codes."* Nobody wants you to dump your entire code here - so that works out well. OTOH - For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). (Oh, and yes 'lack of MCVE' is a close reason.) – Andrew Thompson Apr 03 '16 at 05:37
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. – Andrew Thompson Apr 03 '16 at 05:38

0 Answers0