You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
53 lines
1.6 KiB
10 months ago
|
/*
|
||
|
* Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
|
||
|
* TeamDev PROPRIETARY and CONFIDENTIAL.
|
||
|
* Use is subject to license terms.
|
||
|
*/
|
||
|
|
||
|
package com.example.jxbrowser;
|
||
|
|
||
|
import com.teamdev.jxbrowser.chromium.Browser;
|
||
|
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
|
||
|
import com.teamdev.jxbrowser.chromium.swing.DefaultDialogHandler;
|
||
|
import com.teamdev.jxbrowser.chromium.swing.DefaultDownloadHandler;
|
||
|
import com.teamdev.jxbrowser.chromium.swing.DefaultPopupHandler;
|
||
|
|
||
|
import java.beans.PropertyChangeEvent;
|
||
|
import java.beans.PropertyChangeListener;
|
||
|
|
||
|
/**
|
||
|
* @author TeamDev Ltd.
|
||
|
*/
|
||
|
public final class TabFactory {
|
||
|
|
||
|
public static Tab createFirstTab() {
|
||
|
return createTab("https://www.teamdev.com/jxbrowser");
|
||
|
}
|
||
|
|
||
|
public static Tab createTab() {
|
||
|
return createTab("about:blank");
|
||
|
}
|
||
|
|
||
|
public static Tab createTab(String url) {
|
||
|
Browser browser = new Browser();
|
||
|
BrowserView browserView = new BrowserView(browser);
|
||
|
TabContent tabContent = new TabContent(browserView);
|
||
|
|
||
|
browser.setDownloadHandler(new DefaultDownloadHandler(browserView));
|
||
|
browser.setDialogHandler(new DefaultDialogHandler(browserView));
|
||
|
browser.setPopupHandler(new DefaultPopupHandler());
|
||
|
|
||
|
final TabCaption tabCaption = new TabCaption();
|
||
|
tabCaption.setTitle("about:blank");
|
||
|
|
||
|
tabContent.addPropertyChangeListener("PageTitleChanged", new PropertyChangeListener() {
|
||
|
public void propertyChange(PropertyChangeEvent evt) {
|
||
|
tabCaption.setTitle((String) evt.getNewValue());
|
||
|
}
|
||
|
});
|
||
|
|
||
|
browser.loadURL(url);
|
||
|
return new Tab(tabCaption, tabContent);
|
||
|
}
|
||
|
}
|