You custom painting is done in the CountryPolygon class. Since you are using a null layout the default size of these components is (0, 0), so the painting of your polygons is done outside the bounds of the class and there is nothing to see.
You need to set the size of each of these components.
Not sure, but maybe you can use the approach found in Custom Painting Approaches. The DrawOnComponent
example keeps an ArrayList of Rectangles to draw. In your case you can change this to use to hold Shape
objects and then use the fillShape(...)
method of Graphics2D to do the painting.
Edit:
The width/height of (30, 30) would still be wrong
Point[] poly2 = new Point[] { new Point(50, 10), new Point(80, 10), new Point(80, 40), new Point(50, 40) };
You are using points like (80, 10) which is well outside the (30, 30) size. You really need to make the size of each component the size of the parent panel.