Class BrowserHelper


  • public class BrowserHelper
    extends Object
    A little helper class for browser related stuff.

    The openURL method was originally based on Bare Bones Browser Launch, which has been placed in the public domain.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Properties

        protected static Properties m_Properties
        the general properties.
    • Constructor Detail

      • BrowserHelper

        public BrowserHelper()
    • Method Detail

      • openURL

        public static String openURL​(String url)
        Opens the URL in the system's default browser.
        Parameters:
        url - the URL to open, use tab to separate multiple URLs
        Returns:
        null if executed OK, otherwise error message
      • openURL

        public static String openURL​(Component parent,
                                     String url)
        Opens the URL in the system's default browser.
        Parameters:
        parent - the parent component
        url - the URL to open, use tab to separate multiple URLs
        Returns:
        null if executed OK, otherwise error message
      • openURL

        public static String openURL​(Component parent,
                                     String url,
                                     boolean showDialog)
        Opens the URL in the system's default browser.
        Parameters:
        parent - the parent component
        url - the URL to open, use tab to separate multiple URLs
        showDialog - whether to display a dialog in case of an error or just print the error to the console
        Returns:
        null if executed OK, otherwise error message
      • openURL

        public static String openURL​(Component parent,
                                     String cmd,
                                     String url,
                                     boolean showDialog)
        Opens the URL in a custom browser.
        Parameters:
        parent - the parent component
        cmd - the browser command-line
        url - the URL to open
        showDialog - whether to display a dialog in case of an error or just print the error to the console
        Returns:
        null if executed OK, otherwise error message
      • createLink

        public static JLabel createLink​(String url,
                                        String text)
        Generates a label with a clickable link.
        Parameters:
        url - the url of the link
        text - the text to display instead of URL. if null or of length 0 then the URL is used
        Returns:
        the generated label
      • getProperties

        public static Properties getProperties()
        Returns the properties that define the editor.
        Returns:
        the properties