开发者

How do I move a Java JFrame partially off my Linux desktop?

I'm writing a Java application with movable frames, and I've come across a quirk in Linux. I'm running GNOME 2.16.0 under CentOS.

When I use JFrame.setBounds to set the bounds to any location that's half off the screen, it actually sets the location of the frame to be as close as possible to the bounds specified while still staying completely on the screen.

How开发者_JS百科 do I tell Java to tell GNOME to actually put the frame where I specify, even if that's half off the screen?

Here's some sample code that demonstrates the problem, assuming that -50, 50 is off-screen. The frame can still be dragged off the screen by the title bar, but any calls to setLocation or setBounds don't work.

This works fine in Windows.

JFrame frame = new JFrame();
frame.setPreferredSize(new Dimension(200, 200));
frame.pack();
frame.setVisible(true);
frame.setLocation(-50, 50);


I don't think it's possible in Java, but I'd enjoy being proved wrong. I see it as a feature, meant to reduce the risk of lost windows. A similar thing happens on Mac OS X and Ubuntu. Here's a primitive example for tinkering. Maybe somebody can try in on Windows.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜