开发者

Setting frame to start at bottom left in java

Ive got a pretty simple reqeust. Ive a program that displays code runnign from 开发者_如何学Cright to left. like a marquee.

Im looking to set the location to bottom left for it to start, instead of the top left.

eg

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

something similar to float right would be what i had in mind.

regards, Overtone


One possibility would be to grab the default screen configuration, use that to get the default boundaries of the screen then use that to place the window. Something like:

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);


This would always place the window above the taskbar...

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜