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