JavaFX Hyperlink


JavaFX Hyperlink Tutorials:

The JavaFX Hyperlink UI control is like a label/button which can be a graphics or text which responds to clicks and rollovers.

It is similar to anchor links on webpages.

States of Hyperlink are un-visited, clicked and visited link.

Constructors :

  • Hyperlink()Creates a hyperlink with no label.
  • Hyperlink(String text)Create a hyperlink with the specified text as its label.
  • Hyperlink(String text, Node graphic)Create a hyperlink with the specified text and graphic as its label.

Creating graphical Hyperlink :

To create a Hyperlink link.

Hyperlink link = new Hyperlink();

We can use setText() method to set the text for hyperlink AS


To set image first we take image from source and make a reference to it AS

Image logo = new Image(new File("javafxtuts.jpg"));

And at last using setGraphics() to set it to hyperlink AS

link.setGraphic(new ImageView (logo));


Example of hyperlink:


Output :


Leave A Reply