Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Netscape/Mozilla applet resizing problem

843807May 19 2003 — edited May 22 2003
I'm trying to resize an applet, based on but not equal to the size of the browser window. This in an exerpt from the HTML wrapper for the applet that I've gotten to work with Internet Explorer 5.0

----

<body onLoad="resize()" onResize="resize()"
topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<script language="JavaScript">
function resize() {
var w_newWidth, w_newHeight;
var MAX_WIDTH=1600, MAX_HEIGHT=1200;
if (navigator.appName.indexOf("Microsoft") != -1){
w_newWidth=document.body.clientWidth;
w_newHeight=document.body.clientHeight-4;
}else{
var netscapeScrollWidth=15;
w_newWidth=window.innerWidth-netscapeScrollWidth;
w_newHeight=window.innerHeight-netscapeScrollWidth;
}
if (w_newWidth>MAX_WIDTH)
w_newWidth=MAX_WIDTH;
if (w_newHeight>MAX_HEIGHT)
w_newHeight=MAX_HEIGHT;


document.myApplet.setBrowserViewport(w_newWidth,w_newHeight);

// this works for IE5.0
document.myApplet.width = document.myApplet.pageDimension.width;
document.myApplet.height = document.myApplet.PageDimension.height;

}
window.onResize = resize;
window.onLoad = resize;
</script>

<applet name="myApplet" code="myApplet.class"></applet>

------

public void setBrowserViewport(int width, int height){
viewportDimension.setSize(width,height);
setPageDimensions();
resize(pageDimension);
redraw();
}

public void redraw(){
paint(getGraphics());
}

-------

Calling setBrowserViewport causes new page dimensions to be calculated which are then set to the browser's applet size. Setting the height and width properties of the java applet resizes what portion of the java applet is displayed, when using this example in internet explorer 5.0. When I try using this example in Netscape 7 and Mozilla 1.3 the size of the displayed portion of the applet, doesn't change at all in Netscape, and changes only in the horizontal dimension in Mozilla 1.3

Does anyone know anything about how to make this example work with Mozilla based brosers as well as Internet Explorer?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2003
Added on May 19 2003
1 comment
127 views