resizing applet in browser
来源:互联网 发布:unity3d文件解包 编辑:程序博客网 时间:2024/05/25 23:57
With applets, sometimes the browser acts as the applet's frame. This prevents the user from mistaking the browser window for a separate application and closing it. With this approach, the applet does not resize itself as the user resizes the browser—but there are ways to do this.
The problem is because of the hard-coded applet dimensions the <APPLET> tags. Regardless of the fact that your applet may be using layout managers, it won't adjust its components accordingly. Enter JavaScript to solve this dilemma!
We'll use JavaScript to handle the browser's onResize and onLoad events and pass on new dimensions to the applet. The applet can then override 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:
Internet Explorer and Netscape Navigator have somewhat different implementations of JavaScript. 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 also 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 (see "Which Browser is Running Me?"). Netscape does not include the width of the scrollbars, and does not let you access this length, so 15 pixels are 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. The Java code to support the dynamic resizing is trivial. The applet's setSize() method must be overridden to call the validate() method.
This approach has been tested on version 4.x of IE and Netscape for Microsoft Windows. Unix browsers are a little behind in their implementation of JavaScript.
- resizing applet in browser
- fest + selenium进行In-browser Applet自动化测试
- browser 支持java applet
- Disable Column Resizing in ListView
- Resizing LVM Volumes in Linux
- EasySize - Dialog resizing in no time!
- EasySize-Dialog-resizing-in-no-time
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- Applet Browser Script中代码问题
- 关于View in Browser
- Storing data in browser
- UEFI varstore in Browser
- JavaScript in the browser
- First Applet in OpenGL
- How to prevent resizing of views in a splitter window
- 使用ibatis操作数据库的封装
- 加密asp.net
- /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
- (构思)网站运营分析之用户行为分析
- BytesToWrite=0
- resizing applet in browser
- 一个自动化风格编码的文档自动生成!支持C++,Java
- C++ 基础类型
- 动态创建类
- ClassLoader
- 走出误区 本本电池科学保养指南
- 浮动窗口的创建。
- javascript:window.location 详细用法
- 命令行下使用GWT