Class: HyperlinkLabel

Inherits:
JLabel
  • Object
show all
Defined in:
lib/life_game_viewer/view/life_game_viewer_frame.rb

Overview

JLabel that a) provides a clickable link that launches the default browser with the passed URL, b) makes the text appear like a hyperlink, and c) sets the tooltip text to be the URL.

Defined Under Namespace

Classes: ClickAdapter

Instance Method Summary collapse

Constructor Details

#initialize(url, caption, tool_tip_text) ⇒ HyperlinkLabel

Returns a new instance of HyperlinkLabel.



229
230
231
232
233
234
# File 'lib/life_game_viewer/view/life_game_viewer_frame.rb', line 229

def initialize(url, caption, tool_tip_text)
  text = "<html><a href=#{url}>#{caption}</a></html>"  # make it appear like a hyperlink
  super(text)
  self.tool_tip_text = tool_tip_text
  add_mouse_listener(ClickAdapter.new(url))
end