I'm using Java JxBrowser to display a website on my swing application. When clicking on a link on this website it will normally open a new tab (in google chrome for example). But my application is opening a popup to display the new window. Is it possible to update the jframe of my application, so that the popup stays in the jframe? Thanks!
You can write your own PopupHandler
to choose where your new Browser
is going to appear :
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
com.teamdev.jxbrowser.chromium.Browser browser = new com.teamdev.jxbrowser.chromium.Browser();
com.teamdev.jxbrowser.chromium.swing.BrowserView browserView = new com.teamdev.jxbrowser.chromium.swing.BrowserView(browser);
browser.setPopupHandler(new com.teamdev.jxbrowser.chromium.PopupHandler() {
@Override
public com.teamdev.jxbrowser.chromium.PopupContainer handlePopup(com.teamdev.jxbrowser.chromium.PopupParams params) {
return new com.teamdev.jxbrowser.chromium.PopupContainer() {
@Override
public void insertBrowser(com.teamdev.jxbrowser.chromium.Browser popupBrowser, Rectangle initialBounds) {
// do something with popupBrowser
com.teamdev.jxbrowser.chromium.swing.BrowserView popupBrowserView = new com.teamdev.jxbrowser.chromium.swing.BrowserView(
popupBrowser);
frame.getContentPane().removeAll();
frame.getContentPane().add(popupBrowserView, BorderLayout.CENTER);
frame.getContentPane().validate();
frame.getContentPane().repaint();
}
};
}
});
frame.getContentPane().add(browserView, BorderLayout.CENTER);