package com.ts3client.ui; import javax.swing.JOptionPane; import java.awt.Component; import java.awt.Desktop; import java.net.URI; /** Opens http(s) links from chat messages and descriptions in the system browser. */ final class Links { private Links() { } static void open(String href, Component parent) { try { URI uri = new URI(href); String scheme = uri.getScheme() == null ? "" : uri.getScheme().toLowerCase(); if (!scheme.equals("http") && !scheme.equals("https") && !scheme.equals("ftp")) return; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop.getDesktop().browse(uri); return; } } catch (Exception ignored) { } JOptionPane.showInputDialog(parent, "Could not open the link. Copy it instead:", href); } }