java 叠加层_java中不可选择的叠加层

只有我能看到实现这一点的选项是使用JNA,这是有效的.

你必须参考

JNA库

public class Main

{

public static void main(String[] args)

{

TestFrame frame = new TestFrame();

frame.setVisible(true);

WinDef.HWND hwnd = User32.INSTANCE.FindWindow("SunAwtFrame", "Transparent Window");

int wl = User32.INSTANCE.GetWindowLong(hwnd, WinUser.GWL_EXSTYLE);

wl = wl | 0x80000 | 0x20;

User32.INSTANCE.SetWindowLong(hwnd, WinUser.GWL_EXSTYLE, wl);

}

public static long getHWnd(Frame f) {

return f.getPeer() != null ? ((WComponentPeer) f.getPeer()).getHWnd() : 0;

}

static class TestFrame extends JFrame

{

public TestFrame()

{

super("Transparent Window");

setUndecorated(true);

setBackground(new Color(0, 0, 0, 0));

setAlwaysOnTop(true);

setSize(800, 600);

// Without this, the window is draggable from any non transparent

// point, including points inside textboxes.

getRootPane().putClientProperty("apple.awt.draggableWindowBackground", false);

getContentPane().setLayout(new java.awt.BorderLayout());

getContentPane().add(new JTextField("text field north"), java.awt.BorderLayout.NORTH);

getContentPane().add(new JTextField("text field south"), java.awt.BorderLayout.SOUTH);

}

@Override

public void paint(Graphics g)

{

super.paint(g);

g.setColor(Color.BLUE);

g.fill3DRect(0,0,100,100,false);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值