0

This is my current code for the open URL part. How can I modify it so it always opens in the same browser window? This is not javascript.

    try{
        String url = "www.google.ca"+sn;

        java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
    }
    catch (Exception e) {}

    }          

This function is called many times where sn is a random new page on google. How can i replace the current page it opens?

1 Answers1

0

AFAIK, there is no general, portable, way to do this. Depending on the browser and the platform, you may be able to do non-portable things to tell an existing browser instance to open a different page. However, the standard Java APIs don't support this. (For a start, it may not be technically implementable for some browsers / platforms.)

Another approach might be to use an embedded Java browser; see Is there a way to embed a browser in Java?

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216