I am using this code in a jbutton to open a webpage from my java application.
try {
//Set your page url in this string. For eg, I m using URL for Google Search engine
String url = "http://www.google.com";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
}
catch (java.io.IOException e) {
System.out.println(e.getMessage());
}
Though, when i click the button twice, it opens a new tab.
It will eventually be used in a loop to open different websites upon click.
is there anyway to stop it from opening a new tab and just open the next webpage on the current tab?
or close out the last tab before opening a new tab?