开发者

JWebBrowser how to navigate dynamically

I want to navigate to a particular url in JWebBrowser. What I did:

    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {                                
            getEngine().getWebBrowserFrame().getWebBrowserOuterPanel().getWebBrowser().navigate("http://en.wikipedia.org/wiki/Bell_number");                
            getEngine().getWebBrowserFrame().setVisible(true);                          
        }
    });

getEngine().getWebBrowserFrame().getWebBrowserOuterPanel().getWebBrowser() method returns the JWebBrowser, which resides withing WebBrowserOuterPanel of WebBrowserFrame and the getEngine().getWebBrowserFrame() retu开发者_如何学Pythonrns WebBrowserFrame.

But the problem is that it does not navigate. What I am doing wrong?


Does navigate("http://en.wikipedia.org/wiki/Bell_number") return true? If it does then you're doing nothing wrong (according to the documentation) and it might be some bug in the component itself.


Is the frame that contains the web browser visible? If it is not, then the web browser never gets created and the navigate call is just waiting for this to happen.

If the purpose is to not show the parent frame, then you need at least to call frame.addNotify() to activate native components creation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜