Class Hyperlink<T extends Hyperlink<T>>


public class Hyperlink<T extends Hyperlink<T>> extends A<T>
Represents an HTML hyperlink, extending the <a> (anchor) element.

The Hyperlink class is a convenience wrapper around the A element, providing a more descriptive class name for creating clickable links that navigate to other pages, resources, or locations within the same page. It inherits all functionality from the A class while offering semantic clarity.

Features:

  • Alternative, more descriptive name for the A element
  • Supports navigation to URLs and anchors
  • Configurable link target (same window, new tab, etc.)
  • Inherits all anchor element attributes and methods

Usage:


 // Create a simple hyperlink
 Hyperlink link = new Hyperlink("https://example.com", "Visit Example");

 // Create link opening in new tab
 Hyperlink newTabLink = new Hyperlink(
     "https://example.com",
     Target.BLANK,
     "Open in New Tab"
 );

 // Create link with custom target
 Hyperlink customLink = new Hyperlink(
     "/page.html",
     "_parent",
     "Go to Page"
 );
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Hyperlink

      public Hyperlink()
      Constructs an empty hyperlink element.

      Creates a hyperlink without an href or text content. These should be set using inherited methods from the A class.

    • Hyperlink

      public Hyperlink(String href)
      Constructs a hyperlink with the specified URL.
      Parameters:
      href - the destination URL for the hyperlink
    • Hyperlink

      public Hyperlink(String href, String text)
      Constructs a hyperlink with URL and link text.
      Parameters:
      href - the destination URL for the hyperlink
      text - the visible text for the link
    • Hyperlink

      public Hyperlink(String href, String target, String text)
      Constructs a hyperlink with URL, target, and link text.
      Parameters:
      href - the destination URL for the hyperlink
      target - the target window/frame name (e.g., "_blank", "_self")
      text - the visible text for the link
    • Hyperlink

      public Hyperlink(String href, Target target, String text)
      Constructs a hyperlink with URL, typed target constant, and link text.
      Parameters:
      href - the destination URL for the hyperlink
      target - the target constant (e.g., Target.BLANK, Target.SELF)
      text - the visible text for the link