Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
<APPLET> tags. Therefore, despite the fact that your applet may be using layout managers, it won't adjust its components accordingly.
A little JavaScript easily remedies this problem.onResize and onLoad events and forward new dimensions to the applet. The applet overrides the setSize() method to revalidate its component layout, and thus let its layout manager adjust itself to the new size. The HTML looks
like this:
<HTML>
<HEAD>
<TITLE>Resizable Applet Demo</TITLE>
</HEAD>
<BODY bgcolor=#C6C3C6 onResize="resize()" onLoad="resize()"
topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<SCRIPT LANGUAGE="JavaScript">
function resize() {
var w_newWidth,w_newHeight;
var w_maxWidth=1600, w_maxHeight=1200;
if (navigator.appName.indexOf("Microsoft") != -1)
{
w_newWidth=document.body.clientWidth;
w_newHeight=document.body.clientHeight;
}else{
var netscapeScrollWidth=15;
w_newWidth=window.innerWidth-netscapeScrollWidth;
w_newHeight=window.innerHeight-netscapeScrollWidth;
}
if (w_newWidth>w_maxWidth)
w_newWidth=w_maxWidth;
if (w_newHeight>w_maxHeight)
w_newHeight=w_maxHeight;
document.myApplet.setSize(w_newWidth,w_newHeight);
window.scroll(0,0);
}
window.onResize = resize;
window.onLoad = resize;
</SCRIPT>
<APPLET NAME="myApplet" CODE="SizeApplet.class" WIDTH=1600
HEIGHT=1200>/APPLET>
</BODY>
</HTML>
Internet Explorer and Netscape Navigator implement JavaScript in slightly different ways. The onResize and onLoad parameters in the <BODY> tag specify the resize event handlers for Internet Explorer, while window.onResize = resize; and window.onLoad = resize; do so for Netscape Navigator. Both methods must be included in order to support the two major browsers. Whenever the browser
frame is loaded or resized, the applet's resize() method is invoked.
Navigator and IE have different methods of accessing the browser window's dimensions. In Navigator, the window object is referenced;
in IE, the document's body object is used. These objects also return slightly different values for the window dimensions.
Thus, it is necessary to determine the browser in which the applet is running before sending the correct window dimensions.
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.
The <APPLET> tag still specifies the applet's Width and Height parameters, but these dimensions now specify the applet's maximum bounds. 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 browser still takes up room for this dimension; thus,
the scrollbars will not show all the information in the window. Signed JavaScript in Netscape has the ability to hide the
scrollbars. The HTML page is also scrolled to the top left corner whenever it is resized to ensure that the applet is fully
visible.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq