When the user resizes the window, the HTML page is reloaded, and the document is rewritten with a new Alternative approachesĪnother approach to resizing the applet is to create the page dynamically each time the window is resized using the It is not supported on the Macintosh platform. Support of this feature is being adopted in more Unix browsers, as the LiveConnect-SDK for Unix is available.
Known limitationsĬurrently, JavaScript-to-Java communication is available in Windows versions of Netscape Navigator 4.0 and up and Internet Explorer 4.0 and up, and in Solaris and Linux versions of Navigator 4.0 and up.
The full source of the applet is available in the Resources section. The example applet has an increment button and a label to illustrate the fact that the applet does not reinitialize when a resize event is processed. public void setSize(int width, int height) The applet's setSize() method must be overridden to call the validate() method.
The Java code to support the dynamic resizing is trivial. The HTML page is also scrolled to the top left corner whenever it is resized to ensure that the applet is fully visible. Signed JavaScript in Netscape has the ability to hide the scrollbars. The browser still takes up room for this dimension thus, the scrollbars will not show all the information in the window. The window's maximum width and height, w_maxWidth and w_maxHeight, are checked in the resize() method to ensure that the applet does not go beyond these bounds. The tag still specifies the applet's Width and Height parameters, but these dimensions now specify the applet's maximum bounds. Netscape does not include the width of the scrollbars, and does not let you access this length, so 15 pixels is used as an offset in the netscapeScrollWidth variable. Thus, it is necessary to determine the browser in which the applet is running before sending the correct window dimensions. These objects also return slightly different values for the window dimensions.
In Navigator, the window object is referenced in IE, the document's body object is used. Navigator and IE have different methods of accessing the browser window's dimensions. Whenever the browser frame is loaded or resized, the applet's resize() method is invoked. Both methods must be included in order to support the two major browsers. The onResize and onLoad parameters in the tag specify the resize event handlers for Internet Explorer, while window.onResize = resize and window.onLoad = resize do so for Netscape Navigator. Internet Explorer and Netscape Navigator implement JavaScript in slightly different ways. W_newHeight=window.innerHeight-netscapeScrollWidth ĭ(w_newWidth,w_newHeight) W_newWidth=window.innerWidth-netscapeScrollWidth Method to revalidate its component layout, and thus let its layout manager adjust itself to the new size.