How to Resize Applets Dynamically within Browser Frames 如何调整程序动态内部的浏览器框架
The problem I was trying to solve was to resize applets when the browser changes size ,这个问题我来解决,是要调整程序,当浏览器大小的变化,
so as to always fill the total displayed area of the browser.因此,作为始终填补共展出面积的浏览器。
Googling I found an article from javaworld -在Google上搜寻我发现一篇文章,从javaworld - Resize applets within browser frames调整程序内部的浏览器框架 . 。
I soon found out that the solution doesn't work on either Internet Explorer 6 or Netscape 7.1.我很快发现,该解决办法是行不通的任何的Internet Explorer 6或Netscape 7.1 。
The key problem is that applet.setSize() method doesn't actually do anything!关键的问题是, applet.setsize ( )方法实际上并不做任何事情!
So I did a bit of digging around and found a simpler solution.因此,我做了一点挖左右,并发现一个更简单的解决办法。
The code shown below creates an applet with the same size as the browser window.代码如下所示创建一个applet程序与大小相同的浏览器窗口。
Whenever the browser changes size the applet is resized dynamically.每当浏览器的变化,大小Applet的大小动态。 This is这是
achieved through the resize() method defined in Javascript.通过调整( )方法定义在JavaScript 。 This method is这种方法是
invoked onLoad and onResize.引用的onload和onresize 。 The code works for the recent versions of代码工程为最新版本
Internet Explorer & Netscape browsers. Internet Explorer中与Netscape浏览器。
The two lines:两行:
document.myApplet.width = width; document.myapplet.width =宽度;
document.myApplet.height = height; document.myapplet.height =高;
are enough to change the width and height of the applet.是足以改变宽度和高度的程序。
Remember to name the applet and refer to it by name.记得名称, Applet与转介给它的名称。
Footnote:注: EU欧盟 has proposed a simpler solution to the original problem which is to set the width and height to 100% in the applet tag.提出了一个简单的解决办法,以原来的问题,就是要设置的宽度和高度为100 % ,在Applet的标记。 And that works for the problem I proposed.和工程的问题,我建议。 Thanks for the solution EU!感谢为解决欧盟!
There are a few additional value to the original proposed solution over the new solution which are:有几个附加价值,以原提议的解决方案较新的解决方案是:
- Finer control over the size of the applet, so for example you can say that the width leaves 20 pixels on both sides, but the height doesn't etc.更精细的控制权大小的程序,所以,例如你可以说,叶片宽度20像素的双方,但高度不等。
- Ability to control the size of the applet from the applet itself.控制能力的大小小程序,从程序本身。 This is a big plus as in one project I am working we have a need to re-size the applet from within the applet.这是一个很大的加作为在一个项目,我的工作,我们有必要重新大小Applet的内部程序。 Now we can do it by calling a Javascript method from the applet.现在我们可以做的,它通过调用一个JavaScript方法,从Applet的。
Filed under提起下 How To如何 , , Java Software Java软件 | |
| |
RSS 2.0 2.0 | |
Email this Article电子邮件此文章
You may also like to read您也可以想读 |





































January 24th, 2004 at 11:56 am 2004年1月24日在上午11时56分
What about use “100%” for applet width and height?如何使用“ 100 % ”为Applet的宽度和高度?
August 29th, 2004 at 9:31 pm 2004年8月29日在下午9点31分
[...] x 0.9.1 resize() showDocument() Internet Explorer 6.0 resize() I had posted a [ … … ] x 0.9.1调整( )的showDocument ( ) Internet Explorer 6.0的大小( )我曾发布了 solution for the applet resize problem解决办法为Applet的调整问题 in an earlier blog entry.在较早时的博客条目。
Comments (0) [...]评论( 0 ) [ … … ]
March 11th, 2005 at 4:23 pm 2005年3月11日在下午4时23分
[...] an it has been allocated, then how to go about it? [ … … ]一,它已拨出,又如何去吗? Last time when faced with this problem I solved it with a nifty piece of Javascript method.去年的时候,面对这个问题i解决它与一漂亮的一块JavaScript方法。 However I soon realized there were few issues with t [...]不过,我很快实现了有几个问题与T [ … … ]
March 11th, 2005 at 4:36 pm 2005年3月11日在下午4时36分
[...] Fox 0.9.1 resize() showStatus() Internet Explorer 6.0 resize() I had posted a solution for the applet resize problem in an earlier blog entry. [ … … ]福克斯0.9.1调整( ) showstatus ( ) Internet Explorer 6.0的大小( )我已发布了解决方案,为Applet的大小问题在先前的博客条目。 This entry was [...]这个项目是[ … … ]
June 23rd, 2005 at 6:07 am 2005年6月23日在上午06时07分
You little beauty - this had been driving me mad.你小美-这已驾驶我疯了。 Your example has lots of unrequired backslashes for some reason though您的例子有很多unrequired反斜线出于某种原因,虽然
June 23rd, 2005 at 6:26 am 2005年6月23日在上午06时26分
@Paul @保罗
The backslashes are an unfortunate artifact of the CMS software I am using.反斜线是一个不幸的伪的CMS软件我使用。
I have removed them now.我已拆除他们现在。
August 12th, 2005 at 1:35 pm 2005年8月12日在下午1时35分
How about if you have frameset and frame is resized, applet does not get resized.如何如果您有框架和帧大小, Applet的不大小。
applet gets resized only after window reload. Applet的大小,得到后,才窗口重新载入。
sequence:序列:
have a frame set with Jtree in one frame有一个框架设置与jtree在一帧
applet in another frame, I want to resize Applet在另一帧,我想调整
the applet when frame is resized.程式时,帧大小。
the window reload, resize it works, but not frame resize by dragging the frame boundary between two frames.窗口重新载入,大小工程,但不是帧大小拖曳帧之间的边界2帧。
June 9th, 2008 at 9:00 am 2008年6月9日上午9:00
The applet is not working anymore该Applet的是没有工作了