Hi!
I'm trying to get QtJambiAWTBridge working for hours now but I can's see any success!
I compiled it using Qt-4.4.0 and QtJambi 4.4.0 (both from Source-Package) and SUN's JDK (build 1.6.0_06-b02 64 Bit) on my Gentoo AMD64-System. Compiling worked fine! The only thing I had to do is to adapt the LIBS-var in the Makefile to locate libjawt correctly.
For running my examples with QtJambiAWTBridge I had to include the path to libjawt.so (I also had to link it to liblibjawt.so.so because QtJambiAwtBridge.jniLibraryName( String ) wants it like that) and to motif21/libmawt.so into Jambi's native library path (Eclipse Project Settings/Java Build Path/Libraries/Jambi_Location/Native Library Location).
My little Java-Example looks like this (my goal is to integrate the Apache Batik SVG-Toolkit eventually):
public class test extends QWidget{
public static void main(String[] args) {
QApplication.initialize(args);
test app = new test(null);
app.show();
QApplication.exec();
}
public test(QWidget parent){
super(parent);
QGridLayout layout = new QGridLayout( this );
QComponentHost b = new QComponentHost( new Button( "push me!" ) );
layout.addWidget( b );
}
}
(Trying it with your example "AwtInQt" brought exactly the same result)
Result:
Application start without any error messages or warnings but the ComponentHost is shown outside my Application window. (It stays in the upper left corner of the screen). Resizing my app-Window causes the ComponentHost also to be resized. But in the app-Window where this ComponentHost actually should be placed a part of my screen is shown disturbedly.
I found out that in QtJambiAwtBridge.RedirectContainer.paint( Graphics ) the following native Library method gets called once:
QtJambiAwtBridge.attach(this, host.nativeId(), false)
(this method returns true in spite of the Component obviously not being attached)
However this method is implemented in qawtintegration.cpp not in qawtintegration_x11.cpp. Therefore I tried to run QtJambiAwtBridge.attachComponent( this, host.nativeId() ) instead which results in the following exception:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Container.java:1022)
at java.awt.Container.add(Container.java:352)
at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge.attachComponent(Native Method)
at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge.access$0(QtJambiAwtIntegration.java:159)
at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge$RedirectContainer.paint(QtJambiAwtIntegration.java:101)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
I don't have any idea how to solve this because changing the superclass of RedirectContainer to Panel instead of Frame does also not have the wanted effect.
Any Ideas?
PS: When I started this experiment there was also a problem with locking the JAWT_DrawingSurface ("Couldn't lock drawing surface" in qawtintegration_x11.cpp around line 44). The lock method permanently returned JAWT_LOCK_ERROR. I absolutely cannot understand why but this error disappeared suddenly after a reboot of my system.