Class HTMLLinkAction

java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.text.HTMLLinkAction
All Implemented Interfaces:
HTMLConvertable

public class HTMLLinkAction extends HTMLTag
Represents an HTML hyperlink (`` tag) that triggers a Java action when clicked. It extends HTMLTag and provides a way to create clickable links that execute a Runnable action.
Author:
Alexey Glazyrin
  • Constructor Details

    • HTMLLinkAction

      public HTMLLinkAction(String text, Runnable action)
      Constructs a new HTMLLinkAction instance with the specified text and action.
      Parameters:
      text - the text to display as the link
      action - the action to execute when the link is clicked
    • HTMLLinkAction

      public HTMLLinkAction(String text, String link)
      Constructs a new HTMLLinkAction instance with the specified text and URL link. When clicked, this link will launch the specified URL using the program's launcher.
      Parameters:
      text - the text to display as the link
      link - the URL to open when the link is clicked
  • Method Details

    • getAction

      public Runnable getAction()
      Returns the action associated with this link.
      Returns:
      the action to execute when the link is clicked
    • toHTML

      public String toHTML(Set<String> outStrings)
      Converts the link to an HTML string, including the necessary JavaScript to trigger the action.
      Specified by:
      toHTML in interface HTMLConvertable
      Overrides:
      toHTML in class HTMLTag
      Parameters:
      outStrings - set of unique strings of text content
      Returns:
      the HTML string representation of the link
    • getId

      public String getId()
      Returns the unique ID of this link action.
      Returns:
      the unique ID of the link action