eclipse (java animation issues)

M

mumia55

Guest
im having lots of problems in running this simple animation.
the program just shows 1 frame, which is the last frame(i believe), on a windows computer, i can easily run this with eclipse, but on a mac, i've got always the same problems! HELP!

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

class chute extends JFrame implements MouseMotionListener{
public JLabel x,y;
public JPanel p1;
public static void main(String[]args){
JFrame janela=new chute();
janela.show();
}
chute(){
setTitle("chute");
getContentPane().setLayout(new BorderLayout());
setSize(300,300);
setLocation(90,90);
p1=new JPanel();
p1.setLayout(new BorderLayout());
x=new JLabel("x");
y=new JLabel("y");
p1.add(x,"North");
p1.add(y,"South");
getContentPane().addMouseMotionListener(this);
getContentPane().add(p1,"South");

}
public void paint(Graphics g){
int d=0;
do{
Graphics2D g2d = ( Graphics2D ) g;
double i=0;
do{
super.paint(g);
double x1=230-i;
double x2=200;
g2d.draw(new Line2D.Double(190,140,225,80));
g2d.draw(new Line2D.Double(190,140,x1,200));
g2d.fill(new Rectangle2D.Double(x1-30,x2-9,30,10));
g.fillOval(100,160,40,40);
i+=0.3;
}while(i<62);
i=0;
double j=0;
do{
super.paint(g);
double x1=198+i;
double x2=200;
g2d.draw(new Line2D.Double(190,140,225,80));
g2d.draw(new Line2D.Double(190,140,x1,200));
g2d.fill(new Rectangle2D.Double(x1-30,x2-9,30,10));
g2d.fill(new Ellipse2D.Double(100-j,160-i,40,40));
j+=0.5;
i+=0.1;
}while(i<30);
d++;
}while(d<2);
}
public void mouseMoved(MouseEvent e){
x.setText("X: "+e.getX());
y.setText("Y: "+e.getY());
}
public void mouseClicked(MouseEvent e){}
public void mouseDragged(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
//calculo de rotaÁ„o
/*public static double calculo1(double x,double y,double b){
double tot=((Math.cos(b*3.14/180)*x)-(Math.sin(b*3.14/180)*y));
return tot;
}
public static double calculo2(double x,double y,double b){
double tot=0;
tot=((Math.cos(b*3.14)*y)+(Math.sin(b*3.14/180)*x));
return tot;
}*/

}
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top