2011-01-24 39 views
2

我有一個非常簡單的reqeust。我是一個從右到左顯示代碼runnign的程序。像一個大帳篷。設置框架從左下角開始在java

我正在尋找設置位置左下角開始,而不是左上角。

frame.setLocation(0,0) is top left. 
frame.setLocation(0,700) moves it as close as i can to the bottom 

類似於右浮動會是什麼,我腦子裏想的東西。

問候,泛音

回答

4

一種可能是搶默認的屏幕配置,用它來得到屏幕的默認邊界,然後用它來放置窗口。喜歡的東西:

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); 
Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); 
int x = (int)rect.getMinX(); 
int y = (int)rect.getMaxY()-frame.getHeight(); 
frame.setLocation(x,y); 
+0

我想通有人會發布一些wouold根據系統適應。但這只是完美的怪胎!謝啦 – OVERTONE 2011-01-24 19:49:59

4

這將始終把任務欄上面的窗口...

Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); 
Insets toolHeight = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration()); 
setLocation(Toolkit.getDefaultToolkit().getScreenSize().width - getWidth(), Toolkit.getDefaultToolkit().getScreenSize().height - getHeight());