JavaSwing中如何让弹出的窗口显示居中
怎样才能使弹出的新窗口居中显示??2.我用JPanle+CerdLayout方式弹出的新窗口怎么是这样的??(下图)一出来就是个最小化的.窗口还得自己拖动才看得到.....
怎样才能使弹出的新窗口居中显示??
2.我用JPanle + CerdLayout方式弹出的新窗口怎么是这样的??(下图)一出来就是个最小化的.窗口还得自己拖动才看得到.. 展开
2.我用JPanle + CerdLayout方式弹出的新窗口怎么是这样的??(下图)一出来就是个最小化的.窗口还得自己拖动才看得到.. 展开
展开全部
private SplashPanel SPLASHPANEL=new SplashPanel();
private int splash_x;
private int splash_y;
private int splash_w;
private int splash_h;
private Container con;
public SplashWindow()
{
con=getContentPane();
con.setLayout(new BorderLayout());
Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension splashsize=SPLASHPANEL.getPreferredSize();
splash_w=splashsize.width;
splash_h=splashsize.height;
splash_x=(int)((screensize.width-splash_w)/2);
splash_y=(int)((screensize.height-splash_h)/2);
con.add(SPLASHPANEL,BorderLayout.CENTER);
setBounds(splash_x,splash_y,splash_w,splash_h);
show();
}
private int splash_x;
private int splash_y;
private int splash_w;
private int splash_h;
private Container con;
public SplashWindow()
{
con=getContentPane();
con.setLayout(new BorderLayout());
Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension splashsize=SPLASHPANEL.getPreferredSize();
splash_w=splashsize.width;
splash_h=splashsize.height;
splash_x=(int)((screensize.width-splash_w)/2);
splash_y=(int)((screensize.height-splash_h)/2);
con.add(SPLASHPANEL,BorderLayout.CENTER);
setBounds(splash_x,splash_y,splash_w,splash_h);
show();
}
参考资料: www.baidu.com
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
frame = new MyWindow();
frame.setLocationRelativeTo(null);
frame.setLocationRelativeTo(null);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询