I wrote a couple of years ago a Java application (Swing) incorporating an OpenOffice Writer component.
The trick relied on some sun.awt classes from the jdk to retrieve the AWT container's handle and pass it to the OO objects:
Code: Select all
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;
}
They don't have those old sun.awt classes, which breaks the code.
Is they any new or cleaner way to integrate a OO Writer component into a Java Swing application ?