help embedding KDE application inside java application
Koos Vriezen
koos.vriezen at xs4all.nl
Sun Nov 9 20:57:45 GMT 2003
On Sat, 8 Nov 2003, Koos Vriezen wrote:
> On Sat, 8 Nov 2003, S.Thanga Prakash wrote:
>
> > I have a requirement to embed KDE application eg,.konqueror,kwrite
> > into a java program..
> >
> > how to do it?
> > help me for the same..
>
> Only way I can think of is
> http://java.sun.com/j2se/1.3/docs/guide/awt/AWT_Native_Interface.html
> and reparent your X11 app main window to this java.awt.Canvas X11 Window.
> Not that I have tried it though..
..what could be more fun than actually try it on a sunday afternoon :-).
Attached something that does all that. However you need to patch kdelibs,
so that you don't need to fight with the wm.
kdelibs.diff: adds a --wid <X11 Window> option for all KDE applications
using KMainWindow (not sure if XConfigureEvent is needed
though, but hacking libkdecore.so is no fun with all that X
restarting..)
x11.c: small demo X11 application that prints its X11 Window to the
stdout, so that you can do 'konqueror --wid xxx'
Canvas.java: the slightly modified SUN demo
Canvas.{h,cpp}: the JNI shared lib sources. I compiled it as
g++ -o libmyRenderingLib.so -shared MyCanvas.cpp \
-I/usr/X11R6/include \
-I/usr/local/jdk/include/linux \
-I/usr/local/jdk/include \
-L/usr/X11R6/lib \
-L/usr/local/jdk/jre/lib/i386 -lX11 -ljawt -fPIC
Run the java program as
LD_LIBRARY_PATH=`pwd` /usr/local/jdk/jre/bin/java MyCanvas
In another console run 'konqueror --wid xxx' where xxx is the window
printed to the stdout of the java program.
There is a small focus issue when ALT-TABing to another window. And of
course patching kdelibs is only doable for private use only. But it does
show that it actually works!
>
> Koos
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: java_kde_embed.tar.bz2
Type: application/octet-stream
Size: 4661 bytes
Desc:
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20031109/28d10bce/attachment.obj>
More information about the kfm-devel
mailing list