[功能描述] ScreenRes是个检测用户屏幕分辨率的applet小程序,有了它,无须你来考虑用户屏幕的分辨率,就可以创建美观的动态页面。ScreenRes是根据GNU General Public共享软件协议的,所以你可以免费使用并修改它。
   HTML文档内容如下:
<applet code="ScreenRes.class" width=300 height=25>
</applet>
[源代码]
/*
 * ScreenRes.java - detects user's resolution
 * Author: Aaron Walker <[email protected]>
 * ScreenRes is distributed under the GNU General Public License.
 */import java.applet.Applet;
import java.awt.*;public class ScreenRes extends Applet {
     int height; 
     int width;   public void init() {
setBackground(Color.white);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); 
     height = d.height;
     width = d.width;
} public void paint(Graphics g) {
String str = "Resolution: " + width + " x " + height;
Font f = new Font("Helvetica", Font.PLAIN, 12);
g.setFont(f);
g.drawString(str, 0, 15);
}
}