当前位置: 首页>>代码示例>>Java>>正文


Java BrowserNavigationCallback类代码示例

本文整理汇总了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;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:37,代码来源:Web.java

示例2: browserNavigationCallbacks

import com.codename1.ui.events.BrowserNavigationCallback; //导入依赖的package包/类
private Vector<BrowserNavigationCallback> browserNavigationCallbacks() {
    if (browserNavigationCallbacks == null) {
        browserNavigationCallbacks = new Vector<BrowserNavigationCallback>();
    }
    return browserNavigationCallbacks;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:7,代码来源:BrowserComponent.java

示例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);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:10,代码来源:BrowserComponent.java

示例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;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:56,代码来源:VServAds.java

示例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;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:56,代码来源:VServAds.java

示例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;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:16,代码来源:WebBrowser.java

示例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;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:12,代码来源:BrowserComponent.java

示例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;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:BrowserComponent.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:8,代码来源:BrowserComponent.java

示例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);
    } 
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:WebBrowser.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:BrowserComponent.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:BrowserComponent.java


注:本文中的com.codename1.ui.events.BrowserNavigationCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。