本文整理汇总了Java中com.codename1.ui.events.BrowserNavigationCallback类的典型用法代码示例。如果您正苦于以下问题:Java BrowserNavigationCallback类的具体用法?Java BrowserNavigationCallback怎么用?Java BrowserNavigationCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrowserNavigationCallback类属于com.codename1.ui.events包,在下文中一共展示了BrowserNavigationCallback类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDemo
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
public Container createDemo() {
Container cnt = new Container(new BorderLayout());
final WebBrowser wb = new WebBrowser();
if(wb.getInternal() instanceof BrowserComponent) {
Button btn = new Button("Add");
final TextArea content = new TextArea();
Container north = new Container(new BorderLayout());
north.addComponent(BorderLayout.CENTER, content);
north.addComponent(BorderLayout.EAST, btn);
cnt.addComponent(BorderLayout.NORTH, north);
content.setHint("Add to web document");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
((BrowserComponent)wb.getInternal()).execute("fnc('" + content.getText() + "');");
}
});
((BrowserComponent)wb.getInternal()).setBrowserNavigationCallback(new BrowserNavigationCallback() {
public boolean shouldNavigate(String url) {
if(url.startsWith("http://sayhello")) {
// warning!!! This is not on the EDT and this method MUST return immediately!
Display.getInstance().callSerially(new Runnable() {
public void run() {
((BrowserComponent)wb.getInternal()).execute("fnc('this was written by Java code!')");
}
});
return false;
}
return true;
}
});
}
cnt.addComponent(BorderLayout.CENTER, wb);
wb.setURL("jar:///Page.html");
return cnt;
}
示例2: browserNavigationCallbacks
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
private Vector<BrowserNavigationCallback> browserNavigationCallbacks() {
if (browserNavigationCallbacks == null) {
browserNavigationCallbacks = new Vector<BrowserNavigationCallback>();
}
return browserNavigationCallbacks;
}
示例3: removeBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* Removes a navigation callback.
* @param callback The callback to call before navigating to a URL.
*/
public void removeBrowserNavigationCallback(BrowserNavigationCallback callback) {
if (browserNavigationCallbacks != null) {
browserNavigationCallbacks().remove(callback);
}
}
示例4: getPendingAd
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected Component getPendingAd() {
if(imageURL == null) {
return null;
}
if(renderNotify != null && renderNotify.length() > 0) {
ConnectionRequest c = new ConnectionRequest();
c.setFailSilently(true);
c.setUrl(renderNotify);
c.setPost(false);
NetworkManager.getInstance().addToQueue(c);
}
if("image".equalsIgnoreCase(contentType)) {
Button adComponent = new Button(){
public void setIcon(Image icon) {
if(icon != null && isScaleMode()){
icon = icon.scaledWidth(Display.getInstance().getDisplayWidth());
}
super.setIcon(icon);
}
};
adComponent.setUIID("Container");
adComponent.getStyle().setBgColor(backgroundColor);
adComponent.getStyle().setOpacity(0xff);
ImageDownloadService imd = new ImageDownloadService(imageURL, adComponent);
NetworkManager.getInstance().addToQueueAndWait(imd);
/*adComponent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Display.getInstance().execute(getAdDestination());
}
});*/
return adComponent;
} else {
WebBrowser wb = new WebBrowser();
if(wb.getInternal() instanceof BrowserComponent) {
BrowserComponent bc = (BrowserComponent)wb.getInternal();
bc.setBrowserNavigationCallback(new BrowserNavigationCallback() {
public boolean shouldNavigate(final String url) {
unlock(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Display.getInstance().execute(url);
}
});
return false;
}
});
}
wb.setURL(imageURL);
return wb;
}
}
示例5: getPendingAd
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* @inheritDoc
*/
protected Component getPendingAd() {
if(imageURL == null) {
return null;
}
if(renderNotify != null && renderNotify.length() > 0) {
ConnectionRequest c = new ConnectionRequest();
c.setFailSilently(true);
c.setUrl(renderNotify);
c.setPost(false);
NetworkManager.getInstance().addToQueue(c);
}
if("image".equalsIgnoreCase(contentType)) {
Button adComponent = new Button(){
public void setIcon(Image icon) {
if(icon != null && isScaleMode()){
icon = icon.scaledWidth(Display.getInstance().getDisplayWidth());
}
super.setIcon(icon);
}
};
adComponent.setUIID("Container");
adComponent.getStyle().setBgColor(backgroundColor);
adComponent.getStyle().setOpacity(0xff);
ImageDownloadService imd = new ImageDownloadService(imageURL, adComponent);
NetworkManager.getInstance().addToQueueAndWait(imd);
/*adComponent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Display.getInstance().execute(getAdDestination());
}
});*/
return adComponent;
} else {
WebBrowser wb = new WebBrowser();
if(wb.getInternal() instanceof BrowserComponent) {
BrowserComponent bc = (BrowserComponent)wb.getInternal();
bc.setBrowserNavigationCallback(new BrowserNavigationCallback() {
public boolean shouldNavigate(final String url) {
unlock(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Display.getInstance().execute(url);
}
});
return false;
}
});
}
wb.setURL(imageURL);
return wb;
}
}
示例6: getBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* The browser navigation callback interface allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
*
* @return the callback interface
*/
public BrowserNavigationCallback getBrowserNavigationCallback(){
if(BrowserComponent.isNativeBrowserSupported()) {
return ((BrowserComponent)this.getInternal()).getBrowserNavigationCallback();
} else {
return null;
}
}
示例7: setBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* Set the browser navigation callback which allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
* @param callback the callback interface
* @deprecated Use {@link #addBrowserNavigationCallback(com.codename1.ui.events.BrowserNavigationCallback) Instead
*/
public void setBrowserNavigationCallback(BrowserNavigationCallback callback){
this.browserNavigationCallback = callback;
}
示例8: getBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* The browser navigation callback interface allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
*
* @return the callback interface
* @deprecated Call {@link #fireBrowserNavigationCallbacks(java.lang.String) } to determine whether navigation should occur for a particulr URL.
*/
public BrowserNavigationCallback getBrowserNavigationCallback(){
return this.browserNavigationCallback;
}
示例9: addBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* Adds a navigation callback.
* @param callback The callback to call before navigating to a URL.
*/
public void addBrowserNavigationCallback(BrowserNavigationCallback callback) {
browserNavigationCallbacks().add(callback);
}
示例10: setBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* Set the browser navigation callback which allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
* @param callback the callback interface
*/
public void setBrowserNavigationCallback(BrowserNavigationCallback callback){
if(BrowserComponent.isNativeBrowserSupported()) {
((BrowserComponent)this.getInternal()).setBrowserNavigationCallback(callback);
}
}
示例11: setBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* Set the browser navigation callback which allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
* @param callback the callback interface
*/
public void setBrowserNavigationCallback(BrowserNavigationCallback callback){
this.browserNavigationCallback = callback;
}
示例12: getBrowserNavigationCallback
import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
/**
* The browser navigation callback interface allows handling a case where
* a URL invocation can be delegated to Java code. This allows binding
* Java side functionality to JavaScript functionality in the same
* way PhoneGap/Cordova work
*
* @return the callback interface
*/
public BrowserNavigationCallback getBrowserNavigationCallback(){
return this.browserNavigationCallback;
}