Open URL in default browser

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.

Just found my solution!! OPening the default browser in a separate thread. Please feel free to comment me, on the code (I do not earn my money as a developer)
private void createScene()
        Platform.runLater(new Runnable()
            @Override
            public void run()
                loadURL(FixedVars.SPONSORLINK);
                WebView view = new WebView();
                webEngine = view.getEngine();
                view.setContextMenuEnabled(false);
                webEngine.locationProperty().addListener(new ChangeListener<String>()
                    @Override
                    public void changed(ObservableValue<? extends String> observable, final String oldValue, final String newValue)
                            if ( !newValue.contains(FixedVars.SPONSORLINK) )
                                System.out.println("newval =: " + FixedVars.SPONSORLINK);
                                Platform.runLater(new Runnable()
                                    @Override
                                    public void run()
                                        loadURL(oldValue);
                                // open the destination URl in the default browser
                                // class will open a new thread
                                BrowserOpener.main(newValue);
                Scene scene = new Scene(view);
                fxContainer.setScene(scene);
    }and the class opening the default browser:
public abstract class BrowserOpener implements Runnable {
     * url string
    private static String uriString;
    public void open(String url) throws Exception{
        URI u = new URI(url);
        java.awt.Desktop.getDesktop().browse(u);
    public void run() {
        try
            open(uriString);
        catch ( Exception ex )
            Logger.getLogger(BrowserOpener.class.getName()).log(Level.SEVERE, null, ex);
    public static void main(String args) {
        (new Thread(new BrowserOpener() {})).start();
        uriString = args;
}

Similar Messages

  • Why do we use open URL in default browser function? What are the uses of it?

    Why do we use "open URL in default browser" function?  What are the uses of it?

    kdm7 wrote:
    Okay.
    So can we keep a web button to access the www.ni.com ? So that web site opens only when button pressed?
    P.S  I,m a newbie.
    Yes, you can also, e.g. include a help file or manual as html and open that in the browser.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Bug report: on LabVIEW 2011 SP1 and Windows 8 'Open URL in default browser.vi'

    Dear colleagues,
    Here is a bug report.
    Culprit: 'Open URL in default browser.vi'.
    System: Windows 8, Professional. LabVIEW 2011 SP1.
    Abnormal behaviour and steps to reproduce:
    Above mentioned VI doesn't work when LabVIEW was started with administrator privilegies. And it works as expected when LabVIEW running in normal (non-administrator) mode. 
    Looking forward to see this fixed.
    Best regards,
    Igor Titov.
    CLD.
    =========================
    Igor Titov, CLA
    WebPager - put LabVIEW front panels into the web page
    Labicom.net

    Hi Igor,
    Unfortunately LabVIEW 2011 SP1 does not support Windows 8. I tested this behavior with LabVIEW 2012 SP1 on Windows 8 and everything worked correctly. 
    Regards,
    Jeff Peacock 
    Product Support Engineer | LabVIEW R&D | National Instruments 

  • Open URL in default Browser java.awt.Desktop was working...

    I downloaded Net Beans 6.5 with JavaFX 1 and now java.awt.Desktop isn't even an option for the imports, is there an alternative method to open URLs from my application?

    No, you aren't wrong.
    It's, and I mean this with all due respect, idiotic.
    I found some code on the net that does the same thing:
    http://www.centerkey.com/java/browser/
    Just one class, very simple.
    But I really would like java.awt.Desktop to work, I want the system tray integration stuff.
    Questions about getting Java 1.6 compatibility (the reason why the import doesn't work) go unanswered. It seems there is some hard coded -target 1.5 in some part of the javafx compiler. I can't figure out how to change it.

  • Open URL in default browser -- doesn't

    I'm trying to open up my help files (located on the computer) from within LabView and get the attached error in the JPEG.  Anyone know how to fix this?
       ...Dan
    Attachments:
    browser.jpg ‏53 KB

    Hi Dan,
    Thanks for posting the screenshot...I see what the problem is.  You are trying to wire a path to the Open URL VI as a string.  When this VI receives a string input, it assumes the string contains a URL...if the VI receives a path input, it assumes the string contains an absolute path to an HTML file on disk...it looks like this is the functionality you need.  Here is a screenshot of how I think your VI should work:
    See how the VI is accepting a path input now instead of a string input?  With the path input, it does not try to escape space characters like it would with a URL string.
    Hope this helps,
    -D
    Message Edited by Darren on 06-07-2006 12:52 PM
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    Open_URL_with_Path_Input.jpg ‏19 KB

  • Open URL in Default Browser help

    I use the Open URL vi to send a command to another computer. e.g. http://xxx.xx.xx.xxx:xxxx/exec?RCO.
    The vi also opens a web page with some return information from the other computer. Can I suppress the openning of that web page?
    Thanks

    I'm not sure why you are using this vi anyway but there is not a way to suppress the opening since the VI is password protected. Why not use TCP or ActiveX with internet explorer.
    Joe.
    "NOTHING IS EVER EASY"

  • Open URL in a browser with POST request from FlashPlayer?

    I have a SWF file that plays locally in Standalone Flash Player 11.2 under Win 8.1.
    I'm using the standard navigateToUrl() function to open a URL in a browser, so it's not published for AIR, I make sure that request data is not empty - it contains my URLvars, the function is user initiated on click, and the request method is POST.
    Still the browser sends a GET request.
    Am I missing something? Is it possible to fix, so it sends POST?
    Thanks!

    Can not post my code properly because it then requires moderation, so plain text:
    var req:URLRequest = new URLRequest(....);
    var vars:URLVariables = new URLVariables();
    vars.xxxx = hub.extras[3];
    vars.yyyy = hub.extras[4];
    req.data = vars;
    req.method = URLRequestMethod.POST;
    navigateToURL(req, "_blank");

  • Open URL in current browser window

    I'm developing an application that works side-by-side with the user's default web browser. The browser communicates with the app through a proxy, and that works great. The issue I'm having is going the other way. So far, I've only been successful opening a new browser window each time. However, it would be much better to be able to open a page in the current window/tab. I mainly want this to work with Firefox (or anything other than IE). Has anyone ever done this, and is this even possible with Java?
    Thanks in advance.

    Desktop.getDesktop().browse() is what I'm using currently. I don't think you understood my problem. Currently it is opening in a new browser window. In Firefox, it's opening in a new tab, since I have it set to open in a new tab instead of new window. But, what I want it to do is open in the CURRENT tab. In other words, navigate from the current page to a new page, just as if the user had typed in an address into the address bar and pressed enter, or just as if he had clicked a standard link on the webpage.

  • Hyperlinks in Entourage no longer open in my default browser Firefox in English

    For a month or so now i have been unable to open any hyperlinks in entourage... they no longer click through to my Firefox default browser...
    Any thoughts?

    Maybe the default setting got changed by mistake? Try setting something else as the default browser, then setting it back to Firefox.

  • Thunderbird does not open URLs in a browser. A bug?

    Did a fresh install of Arch 0.8.
    Thunderbird 2 came with it. On my workstation URLs within an email-body aren't opened in an external browser.
    Neither in konqueror nor in Firefox. Is this a bug that I should report, or do you all have a working thunderbird?
    thanks

    Thank you, it works
    Though I dropped TB now, using kmail instead, feels a lot snappier and looks better.

  • Opening url  in a browser

    i have a url .... i have also cookie for that url . i need to GET (method) that . how do i open that url in a browser ?
    i saw archieves . as the url is Cookie sensitive so i must use HttpUrlConnection class .
    so that i could use the class methods .
    but tell me how do i open the url in the browser ?

    this works if there is[b] NO COOKIE.
    import java.net.*;
    public class Hello
        public static void main(String[] args)
            String cmd = "cmd.exe /C start http://xxxx.com...";
            try
              Process p = Runtime.getRuntime().exec(cmd);
                p.waitFor();
            }catch(Exception e)
                        System.err.println("Error bringing up browser" );                                     
       

  • Open URL in Web Browser from a Java Application

    Hi,
    I have an HTML document that I want to load in a browser window by clicking on a button in my java GUI application.
    Any suggestions?
    Thanks.

    You can use the Process class to start the web browser with the proper command line arguments (depends on the web browser though). Or on windows, you can have your program create a batch file with the code start url (where [url] is your url), and this will open the default web browser when run (again you must run it with a Process).

  • Open url in new browser window

    Hello,
    i am looking for a possibility to open an URL in a new browser window, when the end-user clicked on a button.
    I am aware of the LinkToURL view element. Unfortunately i would prefer to use a button element instead of the LinkToURL elementl. Can anyone provide me with a solution? Maybe there is a possibility to implement the needed coding in the action assigned to the button.
    Thanks,
    Dirk
    Message was edited by:
            Dirk Jäckel

    Hi Dirk,
    Use <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/43/79f82ccbec6fcde10000000a1553f6/frameset.htm">IF_WD_WINDOW_MANAGER</a> method CREATE_EXTERNAL_WINDOW and pass URL parameter in button click event handler. And don`t forget to call OPEN on new window instance.
    Best regards, Maksim Rashchynski.

  • TweetDeck/Adobe Air not opening URLs in the browser in x86_64 system.

    Hi,
    I have managed to setup the last version of the (Adobe Air based) TweetDeck application running in my x86_64 and KDE system. I've gone through all the comments in the AUR entry and installed all the relevant lib32 libraries and such, and it appears to all work fine except for one issue.
    When I click on a URL contained in a tweet, nothing happens. It does not open the URL in Firefox as I would expect. Clicking on other items such as the user's ID or the posting date also do nothing. (I should mention that I have i686 ArchLinux running on another machine, and it handles all this with TweetDeck/Air no problems.) Now I suspect this is an Adobe Air issue rather than TweetDeck specific, but that is only my suspicion.
    I tried running strace on the app, and I can see that at one point it reads the Firefox profiles.ini and the prefs.js for my profile, so I suspect it is trying to do some sort of silly-buggers instead of just launching the /usr/bin/firefox executable with the URL as an argument.
    Any ideas on how I can get this working?
    Thanks.
    E.
    Last edited by ecognito (2012-02-06 04:19:04)

    Hi ecognito,
    what window manager are you using? I had a similar issue with pidgin not opening links in XFCE4 and was able to fix it... but I suspect yours MAY be a different case.

  • Open URL in Previous Browser

    On my page, I have a link to a virtual catalog that I am
    working on. Once the user clicks on the catalog it opens in a new
    window. When viewing the catalog the user can click on any of the
    images which in turn is suppose to redirect to a different browser
    window to go to that page. As of right now, I am using the
    GetUrl("
    http://ToThePage.com","_blank");
    which opens a new browser window.
    What I would like to do is to have the flash document
    redirect the request back to the original browser that had made the
    request for the flash document in the first place. So if I start
    with browser A and clicking a link in that browser opens browser B
    which has an embedded flash document, I would like the flash
    document to redirect the GetUrl back to browser A.
    Thanks,
    Kneale

    replace "_blank" for a window's name i.e. "Wellcome to my
    website".
    I'm not so sure if that's the html name, or the name you gave
    at opening time.
    If the last is the case, just make that main page open in,
    or re-direct your main page to itself to a windows named
    "TheNameYouWant" instead of "_blank"
    I've used it before. "_blank" is not a command, it can be
    named with custom window names.

Maybe you are looking for

  • Can I have multiple iPhones with unique back ups using one icloud account?

    Hello forum users, Can I have multiple iPhones with unique back ups using one icloud account? I would like to back up and restore 4 different iPhones, 1 iPad, a MacBook and 1 MacBook Pro using the same single iCloud account. If so, how is this done?

  • PowerMac G5 will not power up

    Hi all, My computer just croaked on me. It was running fine then suddenly shut down. Now when I press the power button the power light turns on then off, there is a clicking sound, the internal fan starts to turn then stops. All this takes less than

  • Approved SHC not appearing in carry out sourcing

    HI SRM Gurus, In SRM Web, after the creation and apporval of shopping cart, the buyer checked the items in carry out sourcing (professional purchaser- Sourcing- carry out sourcing). In find tab, seacrh using extended seacrh and then filling out the s

  • Smpatch update ALERT: Failed to install patch 121616-02

    I am getting various Failed to install patch alerts when doing smpatch update. Many patches are aparently applied successfuly, but others are not. I do not have Sun Support since it is my personal X86 box. Are other people getting these failures? If

  • Myst V: End of Ages crashes on 128MB VRAM!

    Hi all! I got Myst V as a present and installed it this weekend. The game keeps crashing, I still hear the sound as if the game was proceding normally but my cursor is frozen, I have no access to the desktop, keyboard shortcuts to Force Quit do not w