Mixing JWebBrowser with dockables

Hi,

I have a layout problem when mixing a JWebBrowser component with dockables. The webbrowser bounds is exceeding it’s parent bounds
The problem is occurring when I’m using JFrame / JPanel / CContentArea / CGrid / DefaultSingleCDockable / JScrollPane / JPanel / JWebBrowser
If I remove the JScrollPane from the structure, the layout problem will not appear which proves that this is a heavy/light mixing problem

I used the -Dsun.awt.disableMixing=true property as well as the ConstrainVisibility constructor option when creating the browser. However, with the Dockable component I’m using, it seems using ConstrainVisibility is causing the browser to „gray out“, that’s why I commented that in my code.

Note that using -Dsun.awt.disableMixing=true + ConstrainVisibility worked well with me whenever I used the web browser in the following hierarchy: JFrame / JScrollPane / JPanel / JWebBrowser

However, when the JScrollPane is embedded inside the Dockable component, I have the layout problem.

Chris from the dj native project suggest the following. Could you please advice on how to access this invisible component?

Well, if it gets gray, it is probably because the docking framework adds an invisible component above it.

You need to identify that component. You can for example activate that system property:
-Dnativeswing.components.debug.printShapeComputing=true
it should show the calculations that take place to find what should be hidden. You can see which component result in which subtraction.

Once you have the component, you need to indicate that it does not really hide the browser:
UIUtils.setComponentTransparencyHint(comp, TransparencyType.NOT_VISIBLE);

Hope this helps,
-Christopher

To reproduce the problem maximize the window then minimize it back, the JWebBrowser is overlapping other areas in the window


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;

import bibliothek.gui.dock.common.CContentArea;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;


public class SimpleWebBrowserExample extends JPanel {
    private static final long serialVersionUID = -6811930942366567297L;


    public SimpleWebBrowserExample() {
        super(new BorderLayout());
        CControl control = new CControl();
        CGrid grid = new CGrid(control);
        CContentArea contentArea = control.getContentArea();
        JPanel webBrowserPanel = new JPanel(new BorderLayout());
        JScrollPane scrollPane = new JScrollPane(webBrowserPanel);
        DefaultSingleCDockable dockable = new DefaultSingleCDockable("panel", scrollPane);
        control.addDockable(dockable);
        dockable.setMaximizable(false);
        dockable.setMinimizable(false);
        dockable.setExternalizable(false);
        grid.add(0, 0, 1, 1, dockable);
//If you enable the below line the webbrowser bounds will exceed it's parent  bounds after maximize/minimize
        //JWebBrowser webBrowser = new JWebBrowser(JWebBrowser.destroyOnFinalization());
//If you enable the below line, the webbrowser turns to be gray
        JWebBrowser webBrowser = new JWebBrowser(JWebBrowser.destroyOnFinalization(), JWebBrowser.constrainVisibility());
        webBrowser.navigate("http://www.google.com");
        webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
        contentArea.deploy(grid);
        add(contentArea, BorderLayout.CENTER);
    }

    public static void main(String[] args) {
        System.setProperty("sun.awt.disableMixing", "true");
        NativeInterface.open();
        SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    JFrame frame = new JFrame("DJ Native Swing Test");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.getContentPane().add(new SimpleWebBrowserExample(), BorderLayout.CENTER);
                    frame.setSize(800, 600);
                    frame.setLocationByPlatform(true);
                    frame.setVisible(true);
                }
            });
        NativeInterface.runEventPump();
    }
}

Thank you

There is no direct way to access these invisible components.

You do have access to the source code of DockingFrames. Open the class “JavaVersionWorkaround”, the method “markAsGlassPane” is called by all invisible components. You can add the call to the UIUtils there. Let me know if this helps.

In any case I’ll add a way to get the invisible components in the next version.

Hi Beni,

It works after adding UIUtils.setComponentTransparencyHint(component, TransparencyType.NOT_VISIBLE); in the method “markAsGlassPane” as you said

But to do that I’ve added a dependency from docking frames to the dj native project

Thank you

In the next version I’ll add some kind of listener that is informed about new invisible Components. Then you can remove the dependency.

Hi,

Thank you

I’m facing this problem. Could you please help:

ERROR [AWT-EventQueue-0] helper.AbstractComponent - java.util.MissingResourceException: Can’t find bundle for base name data.bibliothek.gui.dock.core.locale.text, locale en_US
java.util.MissingResourceException: Can’t find bundle for base name data.bibliothek.gui.dock.core.locale.text, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:962)
at bibliothek.gui.DockController.createDefaultTextScheme(DockController.java:379)
at bibliothek.gui.DockController.initiate(DockController.java:281)
at bibliothek.gui.DockController.(DockController.java:250)
at bibliothek.gui.DockController.(DockController.java:235)
at bibliothek.gui.dock.common.intern.CDockController.(CDockController.java:48)
at bibliothek.gui.dock.common.intern.EfficientControlFactory.createController(EfficientControlFactory.java:49)
at bibliothek.gui.dock.common.CControl.init(CControl.java:449)
at bibliothek.gui.dock.common.CControl.(CControl.java:427)
at bibliothek.gui.dock.common.CControl.(CControl.java:411)
at bibliothek.gui.dock.common.CControl.(CControl.java:356)
at bibliothek.gui.dock.common.CControl.(CControl.java:324)

Don’t use the build from maven, it is broken.

Thx. That’s was the problem

A little update. Starting with version 1.1.1p6 you can register a custom workaround like this:

			@Override
			public void markAsGlassPane( Component component ){
				UIUtils.setComponentTransparencyHint(component, TransparencyType.NOT_VISIBLE);
			}
		});```