3

In order to embed a C/C++ X11 application into another Java application, is it possible to reparent the X11 top level widget in:

  • a JFrame or a JWindow (catching the X11 window ids of their X11 peers using package sun.awt.x11)?
  • or a JPanel?

I would prefer reparent with a JPanel but I'm not sure it's possible.

paranoia25
  • 626
  • 1
  • 5
  • 23

1 Answers1

2

I searched and found:

A recursive function that will search (starting from the root window) for a window with the desired name

Window windowWithName(Display *dpy, Window top, char *name)
{
        Window *children, dummy;
        unsigned int nchildren;
        unsigned int i;
        Window w = 0;
        char *window_name;

        if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
                return (top);

        if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
                return (0);

        for (i = 0; i < nchildren; i++)
        {
                w = windowWithName(dpy, children[i], name);
                if (w)
                        break;
        }
        if (children)
                XFree((char *) children);
        return (w);
}

You can always open a java.net.Socket to port 6000 or so and speak X11 yourself.
code that might help

reference, hope this help
NOTE: package sun.awt.x11 is no more in jdk7

Community
  • 1
  • 1
Harmeet Singh
  • 2,555
  • 18
  • 21