Class HTMLLinkAction
java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.text.HTMLLinkAction
- All Implemented Interfaces:
HTMLConvertable
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 Summary
ConstructorsConstructorDescriptionHTMLLinkAction(String text, Runnable action) Constructs a new HTMLLinkAction instance with the specified text and action.HTMLLinkAction(String text, String link) Constructs a new HTMLLinkAction instance with the specified text and URL link. -
Method Summary
Methods inherited from class com.amalgamasimulation.desktop.html.HTMLTag
append, attr, backgroundColor, colorToRGBA, copy, fillCopy, font, fontColor, fontFamily, fontSizeInPx, fontStyle, fontWeight, getAttributes, getChildren, lineHeight, marginInPx, maxHeightInPx, maxWidthInPx, paddingInPx, relativeHeight, relativeWidth, removeChildren, style, tag, tag, textAlignment, toCSSMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.html.HTMLConvertable
copy, toHTML
-
Constructor Details
-
HTMLLinkAction
Constructs a new HTMLLinkAction instance with the specified text and action.- Parameters:
text- the text to display as the linkaction- the action to execute when the link is clicked
-
HTMLLinkAction
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 linklink- the URL to open when the link is clicked
-
-
Method Details
-
getAction
Returns the action associated with this link.- Returns:
- the action to execute when the link is clicked
-
toHTML
Converts the link to an HTML string, including the necessary JavaScript to trigger the action.- Specified by:
toHTMLin interfaceHTMLConvertable- Overrides:
toHTMLin classHTMLTag- Parameters:
outStrings- set of unique strings of text content- Returns:
- the HTML string representation of the link
-
getId
Returns the unique ID of this link action.- Returns:
- the unique ID of the link action
-