package org.mcupdater.gui;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.mcupdater.api.Version;

import javax.swing.*;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class SwingBrowser extends BrowserProxy {

	public SwingBrowser() {
		baseComponent = new JTextPane() {
			@Override
			protected InputStream getStream(URL url) throws IOException {
				HttpURLConnection conn = (HttpURLConnection) url.openConnection();
				conn.setRequestProperty("User-Agent", "MCUpdater/" + Version.VERSION);
				return conn.getInputStream();
			}
		};
	}

	@Override
	public void navigate(String navigateTo) {
		try {
			((JTextPane) baseComponent).setPage(navigateTo);
		} catch (IOException e) {
			MainForm.getInstance().baseLogger.severe(ExceptionUtils.getStackTrace(e));
		}
	}
}

@@ -36,110 +36,137 @@
 org.
-apache.commons.lang3.exception.ExceptionUtils;%0Aimport org.mcupdater.api.Version;%0A%0Aimport javax.swing.*
+mcupdater.api.Version;%0A%0Aimport javax.swing.*;%0Aimport javax.swing.event.HyperlinkEvent;%0Aimport javax.swing.event.HyperlinkListener
 ;%0Aim
@@ -272,17 +272,70 @@
 a.net.UR
-L
+I;%0Aimport java.net.URL;%0Aimport java.util.logging.Level
 ;%0A%0Apubli
@@ -713,228 +713,1133 @@
 %7D;%0A%09
-%7D%0A%0A%09@Override%0A%09public void navigate(String navigateTo) %7B%0A%09%09try %7B%0A%09%09%09((JTextPane) baseComponent).setPage(navigateTo);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09MainForm.getInstance().baseLogger.severe(ExceptionUtils.getStackTrace(e)
+%09((JTextPane) baseComponent).setEditable(false);%0A%09%09((JTextPane) baseComponent).setContentType(%22text/html%22);%0A%09%09((JTextPane) baseComponent).addHyperlinkListener(new HyperlinkListener() %7B%0A%09%09%09@Override%0A%09%09%09public void hyperlinkUpdate(HyperlinkEvent e) %7B%0A%09%09%09%09if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) %7B%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09Object o = Class.forName(%22java.awt.Desktop%22).getMethod(%22getDesktop%22, new Class%5B0%5D).invoke(null);%0A%09%09%09%09%09%09o.getClass().getMethod(%22browse%22, new Class%5B%5D %7B URI.class %7D).invoke(o, e.getURL().toURI());%0A%09%09%09%09%09%7D catch (Exception ex) %7B%0A%09%09%09%09%09%09MainForm.getInstance().baseLogger.log(Level.SEVERE, %22Error while trying to handle hyperlink%22, ex);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%0A%09@Override%0A%09public void navigate(String navigateTo) %7B%0A%09%09try %7B%0A%09%09%09((JTextPane) baseComponent).setPage(navigateTo);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09MainForm.getInstance().baseLogger.log(Level.SEVERE, %22Unable to load URL: %22 + navigateTo, e);%0A%09%09%09((JTextPane) baseComponent).setDocument(((JTextPane) baseComponent).getEditorKit().createDefaultDocument());%0A%09%09%09((JTextPane) baseComponent).setText(%22%3CHTML%3E%3CBODY%3EUnable to load page%3C/BODY%3E%3C/HTML%3E%22
 );%0A%09

Fix non-JavaFx browser