As pointed out by @Hunter-mcmillen: you are confused about java operators.
public void mouseMoved(MouseEvent e) {
double distance1 = Math.pow((e.getX() - x1),2);
double distance2 = Math.pow((e.getY() - y1),2); // Math.pow(a,b) == a^b (in a calculator)
setdistance(Math.sqrt(distance1 + distance2));
System.out.println(getdistance());
}
I really recommend that you read more carefully the Java operators before assuming how they work on the language.
EDIT 2:
I recommend also that you create a JPanel or JLabel for this picture, and then load such picture inside this new Jpanel or Label or other component.
public class Paint extends JPanel implements ActionListener {
Mouse swim = new Mouse();
Timer tm = new Timer(7, this);
public void paintComponent(Graphics g) {
// Try this:
ImageIcon swimminghold = new ImageIcon(render.class.getResource("resources/Swimmingpoolns.png"));
swimmingpool = swimminghold.getImage();
JLabel label = new JLabel();
label.setIcon(swimminghold);
label.addMouseMotionListener(swim);
addMouseMotionListener(swim);
label.addMouseMotionListener(swim);
addMouseMotionListener(swim);
//Do something
/* ...*/
}