Embed HWND (Window Handle) in a JPanel

≯℡__Kan透↙ 提交于 2019-12-17 16:39:28

问题


I am trying to embed a HWND (Window Handle) in a JPanel.

Actually, I can embed my HWND into a JFrame, but the embedded window alway stay on top of the other component and I can't move it. If a try to remove all the child component of my JFrame, the HWND stay there. The HWND seems to be paint on top of the JFrame and not as one of is child.

To embed the HWND into the JPanel I use User32 through jna:

User32.SetParent(iage.getRenderHwnd(), (int) getGUIHwnd(j));

And I use this to get the HWND of my JFrame:

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

Is there a way to embed a HWND into a JPanel or to add it into an other component so I can position it like I wan in my UI?

Thanks


回答1:


JPanels are lightweighted components (they have no real native peer). i.e. they use already the handle of the (J)Frame. Look at java.awt.Canvas.



来源:https://stackoverflow.com/questions/4809713/embed-hwnd-window-handle-in-a-jpanel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!