java frame linux_如何將Java JFrame部分移出Linux桌面?

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.

我正在編寫一個帶有可移動框架的Java應用程序,我在Linux中遇到了一個怪癖。我在CentOS下運行GNOME 2.16.0。

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.

當我使用JFrame.setBounds將邊界設置為離屏幕一半的任何位置時,它實際上將幀的位置設置為盡可能接近指定的邊界,同時仍然完全保留在屏幕上。

How do I tell Java to tell GNOME to actually put the frame where I specify, even if that's half off the screen?

我怎么告訴Java告訴GNOME實際把幀放到我指定的位置,即使它離屏幕一半?

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.

下面是一些演示問題的示例代碼,假設-50,50是屏幕外的。框架仍然可以通過標題欄拖出屏幕,但是對setLocation或setBounds的任何調用都不起作用。

This works fine in Windows.

這在Windows中運行良好。

JFrame frame = new JFrame();

frame.setPreferredSize(new Dimension(200, 200));

frame.pack();

frame.setVisible(true);

frame.setLocation(-50, 50);

1 个解决方案

#1

3

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.

我不認為在Java中這是可能的,但我很高興被證明是錯的。我將其視為一項功能,旨在降低失去窗戶的風險。類似的事情發生在Mac OS X和Ubuntu上。這是修修補補的原始例子。也許有人可以在Windows上試試。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值