I copied / pasted your code, and it drew 2 ellipses you wrote about, the only change I made was to replace your MigLayout with null , manually set the frame and panel sizes and delete the frame.pack() call:
import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import javax.swing.JFrame; import javax.swing.JPanel; public class Test { public static void main(String[] args) { JPanel circlePanel = new JPanel() { @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setStroke(new BasicStroke(1));

Update: I can reproduce the problem using Oracle JDK (Java version 1.8.0-ea) instead of OpenJDK. Having received the diamond shape, as indicated in other answers, the scale factor is the main reason for the shape deforming, I donβt know if this should be a suitable behavior, so there must be a mistake in one of these JREs. The following test program works great for both JREs:
import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import javax.swing.JFrame; import javax.swing.JPanel; public class Test { public static void main(String[] args) { JPanel circlePanel = new JPanel() { @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setStroke(new BasicStroke(1));
source share