Class Link

All Implemented Interfaces:
Animatable<Link>, CanDrop<Link>, Clickable<Link>, Draggable<Link>, Focusable<Link>, HandleHotKey<Link>, HandleMouseEvents<Link>, Touchable<Link>

Hyperlink component

With this component, a hyperlink can be placed on the interface. With this, we can link outside the application, but it can be used to link inside it too. This function (the placing of page ids in the URL) has to be enabled however. This can be done enabled or disabled with the use of the ENABLE_PAGE_URL_REWRITE JBStrap parameter.

The link component can also be used to implement an event click handler, so a custom event will run, when the link is clicked. This means that the component can be used to implement custom business functions.

Supported events:

AnimationStart AnimationEnd, Focus FocusOut FocusIn LosesFocus Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd HotKey

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • Link

      public Link()
      Creates a Link component
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(String id)
      Creates a Link component with specified ID
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(String text, String reference)
      Creates a link component with the specified text and URL
      Parameters:
      text - The text that will be displayed. If specified as null, then no text will be displayed.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(String id, String text, String reference)
      Creates a link component with the specified text and URL
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      text - The text that will be displayed. If specified as null, then no text will be displayed.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(Icon icon, String reference)
      Creates a link component with the specified URL and icon
      Parameters:
      icon - The Icon that will be on the component. For the applicable icons, see the Icon enum. If specified as null, no icon will be on it.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(String id, Icon icon, String reference)
      Creates a link component with the specified URL and icon
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      icon - The Icon that will be on the component. For the applicable icons, see the Icon enum. If specified as null, no icon will be on it.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(Icon icon, String text, String reference)
      Creates a link component with the specified URL, text and icon
      Parameters:
      icon - The Icon that will be on the component. For the applicable icons, see the Icon enum. If specified as null, no icon will be on it.
      text - The text that will be displayed. If specified as null, then no text will be displayed.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Link

      public Link(String id, Icon icon, String text, String reference)
      Creates a link component with the specified URL, text and icon
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      icon - The Icon that will be on the component. For the applicable icons, see the Icon enum. If specified as null, no icon will be on it.
      text - The text that will be displayed. If specified as null, then no text will be displayed.
      reference - The URL where the component will navigate to on click
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
  • Method Details

    • setTitle

      public Link setTitle(String text)
      Sets the link text
      Parameters:
      text - The text that will be displayed. If specified as null, then no text will be displayed.
      Returns:
      The link component
    • setIcon

      public Link setIcon(Icon icon)
      Sets the link Icon
      Parameters:
      icon - The Icon that will be on the component. For the applicable icons, see the Icon enum. If specified as null, no icon will be on it.
      Returns:
      The link component
    • getTitle

      public String getTitle()
      Gets the link text
      Returns:
      The link text or null if no link text was specified
    • getIcon

      public Icon getIcon()
      Gets the link Icon
      Returns:
      The link icon or null if no icon was specified
    • setReference

      public final Link setReference(String reference)
      Sets the link reference URL
      Parameters:
      reference - The URL where the component will navigate to on click
      Returns:
      The Link component
    • getReference

      public final String getReference()
      Gets the link reference URL
      Returns:
      The URL where the component navigates to on click or null if no reference was specified
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Link>
      Returns:
      If the componentwas drawn, true, otherwise false