Class CodeHyperlink

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public class CodeHyperlink extends JLabel
A specialized JLabel that acts as a clickable hyperlink for displaying code or JSON content in a popup dialog.
Author:
anahata
See Also:
  • Field Details

    • titleSupplier

      private Supplier<String> titleSupplier
      A supplier for the title of the popup dialog.

      This title is displayed at the top of the dialog window when the hyperlink is clicked. It can be dynamically generated based on the current state.

    • contentSupplier

      private Supplier<String> contentSupplier
      A supplier for the content to display, allowing for lazy loading and formatting.

      The content is fetched only when the user clicks the hyperlink. This is ideal for large JSON payloads or code blocks that require expensive processing.

    • language

      private String language
      The language for syntax highlighting in the popup dialog.

      Supports standard RSyntaxTextArea constants like "json", "java", "xml", etc. If set to "json", the content will be automatically pretty-printed.

  • Constructor Details

    • CodeHyperlink

      public CodeHyperlink(@NonNull @NonNull String labelText, @NonNull @NonNull Supplier<String> titleSupplier, @NonNull @NonNull Supplier<String> contentSupplier)
      Constructs a new CodeHyperlink with default text language.
      Parameters:
      labelText - The text to display for the hyperlink.
      titleSupplier - The supplier for the dialog title.
      contentSupplier - The supplier for the content.
    • CodeHyperlink

      public CodeHyperlink(@NonNull @NonNull String labelText, @NonNull @NonNull Supplier<String> titleSupplier, @NonNull @NonNull Supplier<String> contentSupplier, String language)
      Constructs a new CodeHyperlink with a specific language for syntax highlighting.
      Parameters:
      labelText - The text to display for the hyperlink.
      titleSupplier - The supplier for the dialog title.
      contentSupplier - The supplier for the content.
      language - The language for syntax highlighting (e.g., "json", "java").