ScaledView

Here is an example of using a scaled Graphics environment to create an arbitrarily resizable JPanel. Note that all drawing is done in arbitrary coordinates based on maxX and maxY and scaled to the current Component size. Because mouse coordinates are unscaled, they must be converted before use. The checker can be moved by clicking, dragging or using the arrow keys. Note that all relationships are preserved when resizing the frame changes the aspect ratio. In contrast, the red border is unscaled.