Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

open URL in default browser

AlaricMar 24 2013 — edited Mar 28 2013
Hi All,
I'm very new to this (java(fx) programming) and the last days I'm trying to figure out how I can open the default browser when the user clicks the image (loaded from webpage) in the JFXPanel. This image comes from an openx (ads) server and holds a URL as destination link.
So far all my attempts to accomplish this have failed and I'm lost in this.

Currently when clicking the image, the destination webpage opens in in the same JFXpanel (ofcourse), but I would like to open this in the default browser.

this is what I currently have for initiating the scene from swing
            ap = new AdsPanel();
            ap.init();
            JPanel ad = new JPanel();
            ad.add(AdsPanel.fxContainer);
the class for loading the webpage:
    //@Override
    public void init()
    {
        fxContainer = new JFXPanel();
        fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
        // create JavaFX scene
        Platform.runLater(new Runnable()
        {
            @Override
            public void run()
            {
                createScene();
            }

        });
    }

private void createScene()
    {
        Platform.runLater(new Runnable()
        {
            @Override
            public void run()
            {
                loadURL(FixedVars.SPONSORLINK);
                WebView view = new WebView();

                webEngine = view.getEngine();
                view.setContextMenuEnabled(false);

                Scene scene = new Scene(view);
                fxContainer.setScene(scene);
            }
        });
Hope some can help me out.

Thank you very much in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2013
Added on Mar 24 2013
6 comments
2,954 views