Last Updated on 09 August 2019   |   Print Email
Generally, when embedding a Java applet into an HTML page, the size of the applet is determined by two attributes width and height of the <applet> tag. For example:
That code will set the applet’s size to 640 by 480 pixels. However that size is fixed, so when users resize their browser’s window, the applet’s size does not get updated accordingly.To get the applet resized automatically when the users resize browser’s window, we can use relative value (percentage) for the width and height attributes. For example:
That will set the applet’s size about 80 percent of the browser’s size. So when the browser’s window is being resized, the applet’s size gets updated accordingly (so the specified percentage is always kept). If we want the applet fits the display area in browser’s window, use the maximum percentage value:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.
Comments