JavaSim is an open-source framework for easily developing, viewing, and saving simulations (or other drawings / animations) in Java. The goal is to provide all the desired features of a simulation application (save/copy images, restart, animate) while keeping the simulations themselves simple.
Projects made with JavaSim simply need to draw onto a
Graphics2D object and the rest is handled by JavaSim itself. See a basic example here.