Answer the question
In order to leave comments, you need to log in
How to open a link in a browser on a button click?
Good afternoon.
How to implement opening a link in the browser by clicking on the button.
Answer the question
In order to leave comments, you need to log in
import java.awt.Desktop;
import java.net.URI;
public class Main {
public static void main(final String args[]) {
URI uri = new URI("http://toster.ru");
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question