Java Applets, Web Browser Zoom and DPI settings

If you zoom into a webpage containing an applet, you’ll discover that the applet does not scale. It remains the same size and a solid-colored rectangle will appear around it.

Unfortunately, fewer people have their browser set to 100% zoom any more. It’s a consequence of larger monitors and higher native resolutions. Everything will appear tiny unless you adjust the DPI settings and if you increase DPI, you’ll also have to increase the zoom level in web browsers to compensate.

Is there anything we can do within the applet or within the page containing the applet to scale the applet size appropriately based on zoom and DPI settings?

Good question!
Opera is particularly bad as by default it has a zoom slider on the status bar.
I once accidentally set it to 101% zoom and it took me ages to find out why the applet was not displaying properly in opera.

BTW I just checked how flash dealt with the opera zoom - it scaled flawlessly, but when I closed opera the flash soundtrack carried on to the end even though opera had closed. Huh, what’s new - opera sux.

IIRC once zoomed, the getWidth() and getHeight() of the Applet container should reflect the new size, thus allowing you to use the new values to resize your game.

Once zoomed, it should also throw a ResizedEvent, which you can process with a ComponentListener.