1 19 package org.lucane.applications.helpbrowser; 20 21 import javax.swing.*; 22 import javax.swing.event.*; 23 24 27 public class LinkListener 28 implements HyperlinkListener 29 { 30 private JEditorPane big; 31 private JTextArea mini; 32 private HelpBrowser parent; 33 34 41 public LinkListener(HelpBrowser parent, JEditorPane big, JTextArea mini) 42 { 43 this.big = big; 44 this.mini = mini; 45 this.parent = parent; 46 } 47 48 51 public void hyperlinkUpdate(HyperlinkEvent he) 52 { 53 String url = he.getDescription(); 54 boolean tooltip = false; 55 boolean section = false; 56 57 if(url.startsWith("#tooltip:")) 58 { 59 tooltip = true; 60 url = url.substring(9); } 62 else if(url.startsWith("#section:")) 63 { 64 section = true; 65 url = url.substring(9); } 67 68 if(he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 70 { 71 if(section) 72 this.parent.gotoSection(url); 73 } 74 75 else if(he.getEventType() == HyperlinkEvent.EventType.ENTERED) 77 { 78 if(tooltip) 79 this.mini.setText(url); 80 else if(section) 81 this.mini.setText(parent.tr("gotoSection1") + url + parent.tr("gotoSection2")); 82 } 83 84 else if(he.getEventType() == HyperlinkEvent.EventType.EXITED) 86 { 87 if(tooltip || section) 88 this.mini.setText(""); 89 } 90 } 91 } | Popular Tags |