What i need to do here is get the person to do jumping jacks. Right now i have created a person using basic geometry shapes. I need to get the arms and legs to move. I know the code i have now will not work properly but first i am trying to make the right arm move(rotate). I don't know why my right arm is not moving, i just want to see some movement in the right arm. I think i have the basic setup but something is wrong. (i am using Blue Jay) Thanks for your help.
CODE
import javax.swing.JFrame;
public class JumperApp extends JFrame {
public JumperApp(String title) {
super (title);
this.setSize (800, 450);
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
this.add (new JumperPanel ());
this.setVisible (true);
java.awt.Color color1= new java.awt.Color( 24,16,97);
this.setBackground (color1);
}
public static void main (String[] args) {
JumperApp app = new JumperApp ("Jumpers");
}}
/////////////////////////////////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.geom.*;
import javax.swing.JPanel;
public class JumperPanel extends JPanel {
private Jumper _jumper1;
private Jumper _jumper2;
private Jumper _jumper3;
public JumperPanel() {
_jumper1 =new Jumper(100,100);
//_jumper2 =new Jumper(200,200);
}
public void paintComponent (java.awt.Graphics g) {
java.awt.Color color1= new java.awt.Color( 250,0,0);
java.awt.Color color2= new java.awt.Color( 0,250,0);
java.awt.Color color3= new java.awt.Color( 0,0,250);
_jumper1.paintComponent (g,85,150,Math.PI/1.5, color1);
//_jumper2.paintComponent (g,85,150,Math.PI/1.5);
}}
////////////////////////////////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.geom.*;
import javax.swing.JPanel;
public class Jumper extends JPanel
implements java.awt.event.ActionListener{
private final int interval = 100;
private Ellipse2D.Double _head;
private Rectangle2D.Double _box;
private RoundRectangle2D.Double _body, _leftarm, _rightleg, _leftleg;
private int _x, _y;
private javax.swing.Timer _timer;
private Action _ball, _rightarm;
private double r;
public Jumper(int _x ,int _y) {
super();
_head = new Ellipse2D.Double(_x, _y, 40,40);
_body= new RoundRectangle2D.Double(_x-9,_y+42,60,70,7,7);
r=Math.PI/1.5;
_rightarm= new Action (r);
_rightarm.setRoundRect(_x+53,_y+42,17,60,7,7);
_leftarm= new RoundRectangle2D.Double(_x-28,_y+42,17,60,7,7);
_rightleg= new RoundRectangle2D.Double(_x+39,_y+109,17,60,7,7);
_leftleg= new RoundRectangle2D.Double(_x-14,_y+109,17,60,7,7);
_timer = new javax.swing.Timer(interval, this);
_timer.start();
}
public void paintComponent (Graphics g,int a, int b, double r, Color c) {
super.paintComponent (g);
java.awt.Color colorskin= new java.awt.Color( 240,238,170);
Graphics2D g2 = (Graphics2D) g;
g2.setColor (colorskin);
g2.fill(_head);
g2.rotate(-r, a+72,b);
g2.fill(_rightarm);
g2.rotate(r, a+72,b);
g2.rotate(r, a,b);
g2.fill(_leftarm);
g2.rotate(-r, a,b);
Graphics2D g6 = (Graphics2D) g;
g6.setColor (c);
g6.rotate(-r/3, a+60,b+60);
g6.fill(_rightleg);
g6.rotate(r/3, a+60,b+60);
g6.rotate(r/3, a+15,b+60);
g6.fill(_leftleg);
g6.rotate(-r/3, a+15,b+60);
Graphics2D g3 = (Graphics2D) g;
g3.setColor (c);
g3.fill (_body);
}
public void actionPerformed (java.awt.event.ActionEvent e)
{
_rightarm.move(r);
this.repaint();
}}
///////////////////////////////////////////////////////////////////////////////
public class Action
extends java.awt.geom.RoundRectangle2D.Double{
public Action (double angle){
super();
}
public void move(double angle) {
if (angle>0)
angle=angle+2;
else angle =0;
}}