It would help if you would post a simple example program that demonstrates the problem. There could be several reasons. e.g lack of double buffering, rounding from float to int, etc.
Here is an example that shows movement interpolation. Java has support for that built in. But it can only be used when drawing Shape objects.
This draws two moving circles, the one at the bottom has it’s movement interpolated automatically, the other does not.
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.Ellipse2D;
public class Ball extends JPanel {
static final int WIDTH = 800, HEIGHT = 600;
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
volatile double x1, y1;
volatile double x2, y2;
public static void main(String[] args) {
JFrame frame = new JFrame();
Ball panel = new Ball();
panel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
frame.add(panel);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
panel.start();
}
public void start() {
x1 = 0; y1 = 0;
x2 = 0; y2 = 100;
while(true) {
x1 += 0.43;
x2 += 0.43;
y1 += 0.07;
y2 += 0.07;
repaint();
try {
Thread.sleep(16);
} catch(Exception e) {
}
}
}
public void paint(Graphics _g) {
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.WHITE);
g.fillRect(0, 0, WIDTH, HEIGHT);
g.setColor(Color.BLACK);
g.fillOval((int)x1, (int)y1, 50, 50);
g.fill(new Ellipse2D.Double(x2, y2, 50, 50));
_g.drawImage(image, 0, 0, null);
}
}
However this kind of movement interpolation is not the same as the interpolation used when scaling images.
If you want to interpolate the movement of images it get’s slightly more complicated since Graphics2D does not have a drawImage method that takes in floats or doubles. But it should be doable by scaling the graphics object e.g. by a factor of 0.1 and scaling the image you want to draw by 10 using scaling interpolation. That way you can specify the location to draw the image to 0.1 pixels.