[Qt-jambi-interest] swing component in QDockWidget

Romain Francois romain.francois at dbmail.com
Tue Feb 10 20:20:38 CET 2009


Hello,

My utltimate goal is to mix jedit with qtjambi through the qtjambi to 
awt bridge. You can see the full story here (sorry for those who also 
are registered to jedit-devel mailing list): 
http://romainfrancois.blog.free.fr/index.php?post/2009/02/08/Playing-with-QtJambi-and-Jedit

If I have the following class (based on the examples in the bridge), how 
do I make the swing component to take all the space within the 
QDockWidget ? I am probably missing something obvious here, at least I 
hope it will be obvious to someone ...

I am using this on a gnome desktop, and it seems that when I switch from 
one viewport to the one where this application is, the embedded java 
frame pops out of the Qt widget, is there a way to prevent this ?

package com.trolltech.research.qtjambiawtbridge.examples;

import com.trolltech.qt.gui.*;
import com.trolltech.research.qtjambiawtbridge.QComponentHost;

import javax.swing.*;
import java.awt.*;

public class AwtInQtDock extends QMainWindow {

    public AwtInQtDock() {
       
        setCentralWidget( new QLabel("hello world") );
       
        {
            JPanel panel = new JPanel( new BorderLayout( ) );
                        try{
                            panel.add(
                                    new JEditorPane( 
"http://www.google.com" ),
                                    BorderLayout.CENTER ) ;
                        } catch( Exception e ){ }
           
                        QDockWidget dock = new QDockWidget( ) ;
                        dock.setWidget( new QComponentHost(panel) ) ;
                        addDockWidget(
                            
com.trolltech.qt.core.Qt.DockWidgetArea.LeftDockWidgetArea,
                            dock ) ;
        }

    }

    public static void main(String[] args) {
        QApplication.initialize(args);
                AwtInQtDock app = new AwtInQtDock();
        app.showMaximized();
                QApplication.exec();
                System.exit(0);
    }

}


-- 
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr





More information about the Qt-jambi-interest mailing list