swt設置窗體居中

shell = new Shell();
shell.setSize(
611375);
int width = shell.getMonitor().getClientArea().width;
int height = shell.getMonitor().getClientArea().height;
int x = shell.getSize().x;
int y = shell.getSize().y;
if(x > width)
{
shell.getSize().x 
= width;
}
if(y > height)
{
shell.getSize().y 
= height;
}
shell.setLocation((width 
- x) / 2, (height - y) / 2);
發佈了112 篇原創文章 · 獲贊 3 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章