eclipse anime
im trying to do some animation on eclipse(mac) , and it's not working...
below there's a simple animation i can run on windows.... 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;
}*/
}
(In lieu of getting an eclipse book or browsing the help files....)
From the beginning (or as close as I can get - I've been using eclipse and forget what I've changed from the default settings):
* Start up eclipse and create a new workspace directory.
* File->New...->Project
- create a Java project, name it, and put it where you want.
* File->New...->Class
- create the Java file(s) you want to use and make sure at least one has a main() method.
- saving changes should show any errors in the "Problems" tab at the bottom
* Run->Run...
- Choose "Java application"
- search for the main class if you need to; it might be already set for you
- assuming your program outputs anything, a console tab should show up in your view with the output
I've attached a simple example's view.
Best of luck!