Hi,
When adding chrriis.dj.nativeswing.swtimpl.components.JWebBrowser inside a docking container I won’t be able to see the content of the page anymore
Could you please advise?
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
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 bibliothek.gui.dock.common.action.predefined.CCloseAction;
import bibliothek.gui.dock.common.group.CGroupBehavior;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.util.DirectWindowProvider;
import bibliothek.gui.dock.util.Priority;
import net.miginfocom.swing.MigLayout;
public class ExampleWithDocking {
private static String DOCKBALE_RESTORE = "Restore";
private static String DOCKBALE_DETACH = "Detach";
public ExampleWithDocking() {
JPanel rootPanel = new JPanel();
rootPanel.setLayout(new MigLayout("fill, insets 0"));
final CControl control = new CControl();
control.setGroupBehavior(CGroupBehavior.TOPMOST);
CContentArea contentArea = control.getContentArea();
CGrid grid = new CGrid(control);
control.getController().getTexts().put(Priority.CLIENT, "normalize.in", DOCKBALE_RESTORE);
control.getController().getTexts().put(Priority.CLIENT, "externalize.in", DOCKBALE_DETACH);
control.getController().getTexts().put(Priority.CLIENT, "externalize.out", DOCKBALE_RESTORE);
control.getController().getTexts().put(Priority.CLIENT, "maximize_externalized.out", DOCKBALE_RESTORE);
control.getController().getTexts().put(Priority.CLIENT, "maximize_externalized.out", DOCKBALE_RESTORE);
control.getController().getTexts().put(Priority.CLIENT, "preference.shortcut.externalize.label", DOCKBALE_DETACH);
control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
control.setRootWindow(new DirectWindowProvider(null));
JPanel navigationPanel = new JPanel();
navigationPanel.setLayout(new MigLayout("fill, insets 0"));
JPanel consolePanel = new JPanel();
consolePanel.setLayout(new MigLayout("fill, insets 0 0 0 0"));
DefaultSingleCDockable dockable = new DefaultSingleCDockable("console_dockable", consolePanel);
grid.add(0, 50, 50, 15, dockable);
dockable.setMinimizable(false);
dockable.setMaximizable(false);
dockable.setCloseable(false);
dockable.setExternalizable(false);
dockable.setTitleText("Console");
dockable.setTitleToolTip(null);
dockable.setTitleIcon(null);
contentArea.deploy(grid);
DefaultSingleCDockable navigationDockable = new DefaultSingleCDockable("navigation_dockable", navigationPanel);
grid.add(0, 11, 2, 40, navigationDockable);
navigationDockable.setMinimizable(true);
navigationDockable.setMaximizable(true);
navigationDockable.setCloseable(false);
navigationDockable.setExternalizable(false);
navigationDockable.setTitleText("Navigation");
navigationDockable.setTitleToolTip(null);
navigationDockable.setTitleIcon(null);
contentArea.deploy(grid);
CStack screensStack = new CStack("screens");
screensStack.setHideIfEmpty(false);
control.addStation(screensStack, true);
final JPanel initialScreen = new JPanel();
initialScreen.setLayout(new MigLayout("fill"));
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JWebBrowser webBrowser = new JWebBrowser(JWebBrowser.destroyOnFinalization());
initialScreen.add(webBrowser, "grow");
webBrowser.navigate("www.google.com");
}
});
NativeInterface.runEventPump();
DefaultSingleCDockable initialScreenDockable = new DefaultSingleCDockable("child_1", initialScreen);
initialScreenDockable.setMinimizable(false);
initialScreenDockable.setMaximizable(true);
initialScreenDockable.setExternalizable(true);
initialScreenDockable.setCloseable(true);
initialScreenDockable.setTitleToolTip(null);
initialScreenDockable.setTitleText("Title");
initialScreenDockable.putAction(CDockable.ACTION_KEY_CLOSE, new CCloseAction(control) {
@Override
public void close( CDockable dockable ){
super.close(dockable);
control.remove(dockable.asStation());
}
});
control.addDockable(initialScreenDockable);
screensStack.getStation().add(initialScreenDockable.intern(), 0);
dockable.setVisible(true);
grid.add(40, 11, 48, 40, screensStack);
contentArea.deploy(grid);
rootPanel.add(contentArea, "grow, cell 0 0");
JFrame frame = new JFrame();
frame.setResizable(true);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(800, 800);
frame.setLayout(new MigLayout("fill, insets 0 0 0 0", "[fill, grow]", "[fill, grow]"));
frame.add(rootPanel, "grow");
control.setRootWindow(new DirectWindowProvider(frame));
frame.doLayout();
frame.setVisible(true);
}
public static void main(String[] args) {
new ExampleWithDocking();
}
}```
```import bibliothek.gui.DockController;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.action.DockActionSource;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.intern.AbstractDockableCStation;
import bibliothek.gui.dock.common.intern.CControlAccess;
import bibliothek.gui.dock.common.mode.CNormalModeArea;
import bibliothek.gui.dock.common.mode.ExtendedMode;
import bibliothek.gui.dock.common.perspective.CStationPerspective;
import bibliothek.gui.dock.facile.mode.Location;
import bibliothek.gui.dock.facile.mode.LocationMode;
import bibliothek.gui.dock.facile.mode.ModeAreaListener;
import bibliothek.gui.dock.layout.DockableProperty;
import bibliothek.gui.dock.support.mode.AffectedSet;
import bibliothek.gui.dock.util.DockUtilities;
import bibliothek.util.Path;
public class CStack extends AbstractDockableCStation<StackDockStation> implements CNormalModeArea, SingleCDockable {
private boolean hideIfEmpty;
public CStack(String id) {
CStackDockStation delegate = new CStackDockStation(this);
CLocation stationLocation = new CLocation() {
@Override
public CLocation getParent() {
return null;
}
@Override
public String findRoot() {
return getUniqueId();
}
@Override
public DockableProperty findProperty(DockableProperty successor) {
return successor;
}
@Override
public ExtendedMode findMode() {
return ExtendedMode.NORMALIZED;
}
@Override
public CLocation aside() {
return this;
}
};
init(delegate, id, stationLocation, delegate);
}
public void setHideIfEmpty(boolean hideIfEmpty) {
this.hideIfEmpty = hideIfEmpty;
}
@Override
public CStationPerspective createPerspective() {
/* For this example we do not support perspectives. */
throw new IllegalStateException("not implemented");
}
@Override
public boolean isNormalModeChild(Dockable dockable) {
return isChild(dockable);
}
@Override
public DockableProperty getLocation(Dockable child) {
return DockUtilities.getPropertyChain(getStation(), child);
}
@Override
public void setLocation(Dockable dockable, DockableProperty location, AffectedSet set) {
set.add(dockable);
if (isChild(dockable)) {
getStation().move(dockable, location);
} else {
if (!getStation().drop(dockable, location)) {
getStation().drop(dockable);
}
}
}
@Override
public void addModeAreaListener(ModeAreaListener listener) {
// not required
}
@Override
public Path getTypeId() {
// not required
return null;
}
@Override
public boolean autoDefaultArea() {
return true;
}
@Override
public boolean isChild(Dockable dockable) {
return dockable.getDockParent() == getStation();
}
@Override
public void removeModeAreaListener(ModeAreaListener listener) {
// not required
}
@Override
public void setController(DockController controller) {
// ignore
}
@Override
public void setMode(LocationMode mode) {
// ignore
}
@Override
public CLocation getCLocation(Dockable dockable) {
DockableProperty property = DockUtilities.getPropertyChain(getStation(), dockable);
return getStationLocation().expandProperty(property);
}
@Override
public CLocation getCLocation(Dockable dockable, Location location) {
DockableProperty property = location.getLocation();
if (property == null) {
return getStationLocation();
}
return getStationLocation().expandProperty(property);
}
@Override
public boolean respectWorkingAreas() {
return false;
}
@Override
public boolean isCloseable() {
return false;
}
@Override
public boolean isExternalizable() {
return false;
}
@Override
public boolean isMaximizable() {
return false;
}
@Override
public boolean isMinimizable() {
return false;
}
@Override
public boolean isStackable() {
return false;
}
@Override
public boolean isWorkingArea() {
return false;
}
public boolean hideIfEmpty() {
return hideIfEmpty;
}
public DockActionSource[] getSources() {
return new DockActionSource[] { getClose() };
}
/* This method is called by the CControl and allows access to some inner API that is
* * * hidden from normal clients. */
@Override
protected void install(CControlAccess access) {
access.getLocationManager().getNormalMode().add(this);
}
@Override
protected void uninstall(CControlAccess access) {
access.getLocationManager().getNormalMode().remove(getUniqueId());
}
}
import bibliothek.gui.DockStation;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.StackDockStation;
import bibliothek.gui.dock.action.DockActionSource;
import bibliothek.gui.dock.common.CStation;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.intern.CommonDockable;
import bibliothek.gui.dock.common.intern.station.CommonDockStation;
import bibliothek.gui.dock.event.DockStationAdapter;
import bibliothek.gui.dock.util.DockUtilities;
public class CStackDockStation extends StackDockStation implements CommonDockStation<StackDockStation, CStackDockStation>, CommonDockable {
private CStack delegate;
public CStackDockStation(CStack stack) {
this.delegate = stack;
final Runnable makeVisible = new Runnable() {
@Override
public void run() {
delegate.setVisible(true);
}
};
DockUtilities.disableCheckLayoutLocked();
addDockStationListener(new DockStationAdapter() {
@Override
public void dockableAdded(DockStation station, Dockable dockable) {
DockController controller = delegate.getControl().getOwner().getController();
controller.getHierarchyLock().onRelease(makeVisible);
}
});
}
@Override
public CDockable getDockable() {
return delegate;
}
@Override
public DockActionSource[] getSources() {
return delegate.getSources();
}
@Override
public CStation<StackDockStation> getStation() {
return delegate;
}
@Override
public StackDockStation getDockStation() {
return this;
}
@Override
public CStackDockStation asDockStation() {
return this;
}
@Override
public CommonDockable asDockable() {
return this;
}
}
Thx