如何解决在 Java 11 中使用 Java AWT 获取 Compent 的 Winows 句柄以实现 OpenOffice 集成
几年前,我编写了一个包含 OpenOffice Writer 组件的 Java 应用程序 (Swing)。
该技巧依赖于 jdk 中的一些 sun.awt 类来检索 AWT 容器的句柄并将其传递给 OO 对象:
public static long getHWnd(Component f) {
ComponentPeer compPeer = f.getPeer();
if (compPeer == null) {
return 0;
}
if (compPeer instanceof WComponentPeer) {
return ((WComponentPeer) compPeer).getHWnd();
}
// typically we get here if the peer is of class sun.awt.NullComponentPeer
// (e.g if the Component is a Swing object - apparently these do not have a "peer")
return -1;
}
这在我搬到 OpenJDK 之前一直有效。
在 Java 11 中,Componet#getPeer
不再可用。
在 OpenJDK 中,WComponentPeer
不能作为旧 sun.awt 类的一部分使用
他们还有其他方法可以在 Java11 中检索该句柄吗?
(或者一种将 OO Writer 组件集成到 Java Swing 应用程序中的更简洁的方法?)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。