码迷,mamicode.com
首页 > 其他好文 > 详细

Frame顶层框架合理大小与图标添加源代码

时间:2016-06-09 22:13:00      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

 1 class SizedFrame extends JFrame
 2 {
 3    public SizedFrame()
 4    {
 5       // get screen dimensions
 6 
 7       Toolkit kit = Toolkit.getDefaultToolkit();
 8       Dimension screenSize = kit.getScreenSize();
 9       int screenHeight = screenSize.height;
10       int screenWidth = screenSize.width;
11       
12 
13       // set frame width, height and let platform pick screen location
14 
15       setSize(screenWidth / 2, screenHeight / 2);
16       setLocationByPlatform(true);
17 
18       // set frame icon
19 
20       Image img = new ImageIcon("icon.gif").getImage();
21       setIconImage(img);      
22       
23    }
24 }

 

Frame顶层框架合理大小与图标添加源代码

标签:

原文地址:http://www.cnblogs.com/dangnianhefeng/p/5572785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!