WindowUtilities.java
资源名称:security.rar [点击查看]
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:1k
源码类别:
CA认证
开发平台:
Java
- package org.infosecurity.cryptography;
- /**
- * <p>Title: 中国信息安全组织--窗口管理工具 </p>
- * <p>Description: 中国信息安全组织--窗口管理工具 </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: 中信信息安全组织(CISO)</p>
- * @author 张荣华
- * @version 1.0.2003.0615
- */
- import java.awt.Dimension;
- import java.awt.Window;
- public final class WindowUtilities {
- static public final int TOP = 0;
- static public final int BOTTOM = 1;
- static public final int CENTER = 2;
- static public final int LEFT = 3;
- static public final int RIGHT = 4;
- /**
- * 定位窗口
- * @param w 容器实例
- * @param x 水平位置
- * @param y 垂直位置
- */
- static public void positionWindowOnScreen(Window w, int x, int y) {
- Dimension scrn = w.getToolkit().getScreenSize();
- Dimension win = w.getSize();
- int nx = 0;
- int ny = 0;
- switch(x) {
- case LEFT: nx = 0; break;
- case CENTER: nx = (int)((scrn.width-win.width)/2); break;
- case RIGHT: nx = (int)(scrn.width-win.width); break;
- }
- switch(y) {
- case TOP: ny = 0; break;
- case CENTER: ny = (int)((scrn.height-win.height)/2); break;
- case BOTTOM: ny = (int)(scrn.height-win.height); break;
- }
- w.setLocation(nx,ny);
- }
- /**
- * 居中窗口
- * @param w 窗口实例
- */
- static public final void centerWindowOnScreen(Window w)
- {
- positionWindowOnScreen(w, CENTER, CENTER);
- }
- }