首页>代码>毕设 基于java swing的泡泡堂游戏>/H2003032025-泡泡堂网络游戏的设计与实现/Game/src/net/jeson/game/component/CenterShowDialog.java
package net.jeson.game.component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import javax.swing.JFrame;
/**
* 描述:进入参数Dialog,使显示的图形界面显示居中
* */
public class CenterShowDialog {
// public CenterShowFrame(Frame frame) {
// 若为frame改所有dialog字段为frame
public CenterShowDialog(Dialog dialog) {//目标显示为对话框
dialog.setResizable(false);//不准最大化
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogSize = dialog.getSize();
if (dialogSize.height > screenSize.height) {
dialogSize.height = screenSize.height;
}
if (dialogSize.width > screenSize.width) {
dialogSize.width = screenSize.width;
}
dialog.setLocation((screenSize.width - dialogSize.width) / 2,
(screenSize.height - dialogSize.height) / 2);
}
public CenterShowDialog(JFrame dialog) {//目标显示为对话框
dialog.setResizable(false);//不准最大化
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogSize = dialog.getSize();
if (dialogSize.height > screenSize.height) {
dialogSize.height = screenSize.height;
}
if (dialogSize.width > screenSize.width) {
dialogSize.width = screenSize.width;
}
dialog.setLocation((screenSize.width - dialogSize.width) / 2,
(screenSize.height - dialogSize.height) / 2);
}
public CenterShowDialog(Frame dialog) {//目标显示为对话框
dialog.setResizable(false);//不准最大化
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogSize = dialog.getSize();
if (dialogSize.height > screenSize.height) {
dialogSize.height = screenSize.height;
}
if (dialogSize.width > screenSize.width) {
dialogSize.width = screenSize.width;
}
dialog.setLocation((screenSize.width - dialogSize.width) / 2,
(screenSize.height - dialogSize.height) / 2);
}
}
最近下载更多
vincemokea LV9
8月25日
微信网友_7550654200254464 LV1
6月12日
970319208 LV3
6月9日
微信网友_7398626323435520 LV3
4月29日
zhuyongwei LV1
3月29日
lindali LV1
3月11日
longbadx LV9
1月22日
bingtian1112 LV1
2024年12月23日
微信网友_6802079662936064 LV3
2024年12月12日
lijiuo LV1
2024年12月1日
最近浏览更多
baizhongcai LV24
9月28日
dddding yang LV6
9月15日
浙江螃蟹 LV7
6月24日
唐僧洗头爱飘柔 LV22
6月24日
3334004690 LV11
6月19日
chengjingjingjing
6月18日
暂无贡献等级
limufu LV1
6月17日
1052526237
6月16日
暂无贡献等级
ningrong
6月13日
暂无贡献等级
微信网友_7550654200254464 LV1
6月12日

