application.java

来自「一个java实现的邮件服务器系统 使用邮件客户端工具」· Java 代码 · 共 57 行

JAVA
57
字号
import java.awt.Dimension;
import java.awt.Toolkit;

/*
 * Created on 2004-12-20
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

/**
 * @author liujinghua
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

public class Application {
	boolean packFrame = false;
		/*构造函数*/
		public Application() {
			MainFrame frame = new MainFrame();

			if (packFrame) {
				frame.pack();
			} else {
				frame.validate();
			}
			
			//得到窗口尺寸
			Dimension screenSize = 
				Toolkit.getDefaultToolkit().getScreenSize();
			//得到框架尺寸
			Dimension frameSize  = frame.getSize();
			
			if (frameSize.height > screenSize.height) {
				frameSize.height = screenSize.height;
			}	//框架高度不得高于屏幕高度
			if (frameSize.width > screenSize.width) {
				frameSize.width = screenSize.width;
			}	//框架宽度不得宽于屏幕宽度
			
			//将窗口居中显示
			frame.setLocation(
				(screenSize.width - frameSize.width) / 2,
				(screenSize.height - frameSize.height) / 2);
			//显示窗口
			frame.setVisible(true);	//
		}


		/*主函数*/
		public static void main(String[] args) {
			new Application();
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?