2008年5月22日 星期四

[Java] 如何把 JFrame 顯示畫面放到最大--getMaximumWindowBounds

使用 Toolkit 裡面的 getScreenSize();
你取到的視窗大小是真實的大小,並沒有計算下面的 taskbar 高度.

所以當你使用 getScreenSize() 資訊進行放大視窗時,
你會發現你放的視窗會佔滿整個螢幕包含 taskbar.

所以如果想要取得全螢幕畫面(不含 taskbar), 請使用 GraphicsEnvironment .

 



// 把視窗變成最大
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = ge.getMaximumWindowBounds();
this.setBounds(bounds);





參考資料


http://forum.java.sun.com/thread.jspa?threadID=546044&messageID=2657551



 



by Jing

沒有留言:

張貼留言