What is the best API for creating simple 2D graphics in Java, and how has the landscape changed over time?

Jumping in here—after doing some GUI-heavy Java projects in the last few years, I’ve shifted to JavaFX and haven’t looked back.

If you’re craving a more modern java graphic lib, JavaFX is where the real fun starts. It feels more in tune with today’s UI/UX standards—smooth, stylable, and better integrated with animations.

Canvas canvas = new Canvas(400, 400);
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.strokeLine(0, 0, 200, 200);

It’s still Java, but you get more control and cleaner visuals. Plus, you can mix UI elements and graphics seamlessly—which Swing often struggled with.

:small_orange_diamond: Best for: Applications that blend UI + graphics, or when you want something richer than AWT/Swing.