import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Liikumine2 extends JPanel implements ActionListener{ double x=100, y=50, r=5, dy=1, ddy=0.1; Timer t=new Timer(100, this); public Liikumine2(){ t.start(); } public void paintComponent(Graphics g){ super.paintComponent(g); g.drawOval((int)(x-r), (int)(y-r), (int)(2*r), (int)(2*r)); } public void actionPerformed(ActionEvent e){ y+=dy; dy+=ddy; repaint(); } public static void main(String[] arg){ JFrame f=new JFrame(); f.getContentPane().add(new Liikumine2()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }