I want to position 10 JPanels in a Circle. Every Panel has the same size and the length between two Panels should be the same. So the easiest way i thought is to grab a null-Layout and compute the bounding box by hand via polarcoordiantes:
JPanel panel = new JPanel(null);
int r = 100;
int phi = 90;
for (int i = 0; i < 10; i++) {
JPanel x = new JPanel();
x.setBackground(Color.red);
x.setBounds((int) (r * Math.sin(phi)) + 100, (int) (r * Math.cos(phi)) + 100, 4, 4);
panel.add(x);
phi = (phi + 36) % 360;
}
But that doesnt work! Some items are on the circle, some of them are pixels off... i have a bsolutly no idea why?! I also cant find a LayoutManager that can do that for me, so what to do?