您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 延边分类信息网,免费分类信息发布

Java两种方法实现窗体居中显示的实例分析

2025/2/24 18:02:54发布49次查看
第1种方法:
//setsize(300, 200); pack(); // 得到显示器屏幕的宽、高 int width = toolkit.getdefaulttoolkit().getscreensize().width; int height = toolkit.getdefaulttoolkit().getscreensize().height; // 得到窗体的宽、高 int windowswidth = this.getwidth(); int windowsheight = this.getheight(); //system.out.println(windowswidth+","+windowsheight); this.setbounds((width - windowswidth) / 2,(height - windowsheight) / 2, windowswidth, windowsheight);
第2种方法:
setlocationrelativeto(null);
以上就是java两种方法实现窗体居中显示的实例分析的详细内容。
延边分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product